Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaIntro4.java
More file actions
Latest commit
26 lines (22 loc) · 1.01 KB
/
Copy pathJavaIntro4.java
File metadata and controls
26 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//Project Name: Spectrum 4th Program
publicclassJavaIntro4 {
/*add 4 to the parameter sent to the method and return the result*/
publicstaticdoubleaddFour(doublenum){ // the variable type before the method name is what type will be returned
returnnum + 4; //return is the keyword that tells java to end the method and send the value
}
/*if the boolean named bol is true than print out the double named num*/
publicstaticvoidifTruePrint(booleanbol, doublenum){ //void means the method won't return any value
if (bol){
System.out.println(num);
}
} //this method doesn't return a value
publicstaticvoidmain(String[] args) { //This line lets Java know what to run when you click execute below
booleanb1 = true;
booleanb2 = false;
doublex = 10;
doubley = 20;
System.out.println(addFour(x));
ifTruePrint(b1, x); //if b1 is true print x
ifTruePrint(!b1, y); //if b1 is not true print y
}
}