This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. Create a variable called test of type boolean and assign the variable the value true. | |
boolean test = true | |
//2.Create a variable called a of type int and assign the variable the value 5. | |
int a = 5 | |
/*3.Type in an if statement that adds 1 to a if test has value true and subtracts 1 from a if test has value false. | |
Helpful hint: The DrJava interactions pane will evaluate an expression after you hit the return key if what you have typed in is a valid expression. To keep the interactions pane from evaluating your if statement prematurely, either type the entire statement in one line or place the statement inside braces { }*/ | |
if (test == true) { | |
a + 1;} | |
else { a - 1;} | |
//4.Type a to see the current value of a. If you did everything correctly, it should be 6. |