CPSC 120: Lab Assignment 3

Due by the start of class on Friday, 02/17/2017

Home | Calendar | Announcements | Assignments | Example Code | Notes

Two Loop Problems

  1. Write a program that fills the background with at least 100 colored bars, each stretching either top to bottom or side to side. Each rectangle should be drawn with no outline, and each one should be progressively darker than the one before it. The choice of color is up to you. Here's a purple example:

  2. Write a program that draws 1000 circles, each one of a randomly-chosen size and coordinates. Note that you can generate a random integer within a range by using the random() function, together with an explicit conversion to and int. For example,

    int x = (int) random(1,50);

    Here is one output from my solution:

Turn In

Make a folder in your turn in directory named "lab3". Copy all four of your solutions in to this folder. Consult the Linux tutorial from Lab #0 if you need a reminder of the details.


John H. E. Lasseter