Write correct, successfully-compiling, correctly-running programs to accomplish the following tasks:
- UsingVariables.java -- In the main method of your first program, do the following:
- Declare the following variables, each in a separate, one-line statement (4 statements, total):
- Name: intVar; Type: int
- Name: charVar; Type: char
- Name: dVar1; Type: double
- Name: dVar2; Type: double
- For each of the four variables, initialize each in a separate, one-line statement. (4 statements, total)
- Write println statements (4 statements, total) to announce the current values of each (use your variables in String concatenation):
The current value of intVar is 5
The current value of charVar is 'c'
The current value of dVar1 is 3.7
The current value of dVar2 is 5.5
- Change the values of each variable, and repeat the previous step by announcing the new values of those variables (8 statements, total).
- Swap the values of the double variables (dVar1 and dVar2) without using literals. (Number of statements may vary)
- Write println statements to announce their new values after the swap. (2 statements, total)
- VariablePractice.java -- In the main method of your second program, do the following:
- Declare a byte variable in one statement on one line and initialize it on the next line in another statement. (2 statements)
- Declare a short variable and initialize it in a single, one-line statement. (1 statement)
- Declare two char variables in a single statement. Initialize each on separate lines, in separate statements. (3 statements)
- Declare two boolean variables and initialize both, all in a single one-line statement. (1 statement)
- Declare two double variables and initialize them to 10.0 and 3.0. (Number of statements may vary)
- Declare two int variables and initialize them to 7 and 5. (Number of statements may vary)
- Declare two String variables and initialize them to "hello" and "world". (Number of statements may vary)
- Write println statements with string concatenation expressions to produce the following output (when possible, by performing operations on the previously declared variables, rather than using string literals). 4 statements:
13.0hello
hello, world_75
hello3.07world
12world510.0
In at least 150 words, please address the following questions: - How did the process of creating these programs go for you?
- What were your main challenges and how did you overcome them?
- What did you learn that may be of use as you move along in this class?