Today’s Assignments

 

Practice with for loops

Put all the code for these in the paint() method.

 

Problem 8.1  (p. 136 in white book)

            Display integers.  Write a program to print out the numbers 1 to 10 using a loop.

            Use System.out.println();

            I suggest calling your counting variable i.

 

Problem 8.6 (p. 136 in white book)

            Sum of the integers. 

            Write a program that adds up the numbers 0 to 39 using a loop.

            Check that it gave the right answer by using the formula for the sum of the numbers 0 to n:

            sum = n * (n + 1) / 2

 

Self test problem 8.10 p. 132 in white book

Use nested for loops to draw an apartment building as a collection of rectangles, 3 stories high and 5 stories wide.  See the example on p. 131 in the white book.

 

Challenge problems 8.7

Saw-tooth pattern

            Write the pattern out using

            System.out.print

            And System.out.println

            Use nested for loops.