Starting from:

$10

COP 2800  Assignment 1 Solution

For this assignment you will write a simple Java program. Write a class called Print. This class has only a main method. The main method has a single for loop with an index that increments from 0 to 19. At each iteration of the loop, if the current value of the index is multiple of 3, the loop should print:

“How now

brown cow” using a single print statement.

If the loop index is not divisible by 3, the loop should print:

“How now brown cow” using two print statements, one for the first two words and one for the last two words.


Your output should start out like this:

How now

brown cow

How now brown cow

How now brown cow

How now

brown cow

How now brown cow
How now brown cow

How now

brown cow

How now brown cow

How now brown cow


Examination of different methods to do printing would be helpful as well as a review of escape sequences and a review of the remainder operator should be helpful in this assignment.

If your program compiles, but you get a runtime error stating that main can’t be found, check the signature of your main method to be sure it’s correct.

More products