1. Visit the class web page, and then download DebugSix1, DebugSix2, and DebugSix3 Java files. Each of the files has syntax and/or logical errors. In each case, determine the problem and fix the program. Start with DebugSix3, and then DebugSix2.
2. Write a program that prints all numbers from 1 to 100 inclusive using one of the loop statements. Save the program as Numbers.java
3. Write a program that sums the integers from 1 to 50 (1 + 2 + 3 + 4 + 5….). Save the program as Sum50.java.
4. Complete a below partial program and answer for following question: (1) total number of times the outer loop body is executed, (2) total number of times the inner loop body is executed. Save the program as NestedLoop.java
for (line = 0; line < 4; line++)
{
for (star = 0; star < 5; star++)
System.out.print('*');
System.out.println();
}
Java Assignment 4: (Turn in by email – attach the program)
Due: will be announced by instructor
Score: 10 points
1. Complete a below partial program and change the “while” loop statement to “for” loop statement. Save as WhilToFor.java
years = 0; // initialize the variable years
while ( years < 5 ) { // condition for continuing loop
interest = principal * rate;
principal += interest;
System.out.println(principal);
years++; // update the value of the variable, years
}
2. Write a program using the “for” loop that counts off all the numbers 1, 2, 3, 4, ..., 19, 20, but only print out the numbers that are even (Hint: Use remainder symbol). Save as EvenNums.java