Exercise CozaLozaWoza (Loop & Condition): Write a program called CozaLozaWoza which prints the numbers 1 to 110, 11 numbers per line.
TRY: Modify the program to use nested-if (if ... else if ... else if ... else) instead.
Hints:
public class CozaLozaWoza { // saved as "CozaLozaWoza.java" public static void main(String[] args) { int lowerbound = 1; int upperbound = 110; for (int number = lowerbound; number <= upperbound; ++number) { // Print "Coza" if number is divisible by 3 if (......) { System.out.print("Coza"); } // Print "Loza" if number is divisible by 5 if (......) { System.out.print(.....); } // Print "Woza" if number is divisible by 7 ...... // Print the number if it is not divisible by 3, 5 and 7 if (......) { ...... } // Print a newline if number is divisible by 11; else print a space if (......) { System.out.println(); } } } }
TRY: Modify the program to use nested-if (if ... else if ... else if ... else) instead.
No Comment to " Hints for Exercise CozaLozaWoza (Loop & Condition) "