Assignment 12
Due Tuesday, November 6 at 9:20am on Canvas


Assignment 12.1: Humpty Again! (10 pts)
Humpty dumpty

  • Open Humpty.java from assignment 11
  • Locate the while loop in the program and convert it to the equivalent for loop
  • If you had any problems with your original version of the program, please correct them now (getting help where needed)
  • When you are finished, and your output looks like mine, upload your assignment to Canvas.




Your Output Should Look Like the Following. Note that some values have been omitted for brevity.

1
2
3
Humpty Dumpty
Sat on a wall
6
7

Humpty Dumpty
9
Sat on a wall
11
Humpty Dumpty
13
14
Sat on a wall
Humpty Dumpty
17
18
19
Had a great fall
...

Had a great fall
141
142
143
Humpty Dumpty
Sat on a wall
146
147
Humpty Dumpty
149
Sat on a wall


Assignment 12.2: i and j (10 pts)
  • Create a new Java file called IJ.java.
  • In this assignment, we are going to write another program that uses a for loop. 
  • Within the loop, make the variable i go from -5.0 to 5.0, counting by 0.5
  • Inside the body of the loop, set another variable j to be the current value of i raised to the fourth power
  • For output, you will need to display the current values of both i and j in a chart, as shown below.
  • Note that above the values, you should print out i above the i column and j above the j column.
  • Also, you should display the values to exactly one decimal point.
  • You will need to use tab (how can you print a tab?), System.out.printf and the Math.pow(base,exp) method.
  • When you are finished, upload your source code to Canvas.
Your Output Should Look Indentical to the Following:

i          j
-5.0       625.0
-4.5       410.1
-4.0       256.0
-3.5       150.1
-3.0       81.0
-2.5       39.1
-2.0       16.0
-1.5       5.1
-1.0       1.0
-0.5       0.1
0.0        0.0
0.5        0.1
1.0        1.0
1.5        5.1
2.0        16.0
2.5        39.1
3.0        81.0
3.5        150.1
4.0        256.0
4.5        410.1
5.0        625.0