CSci 1211 Problem set 1. Due Friday, Jan. 23rd at 5pm

Resources: Java drawRect and fillRect methods, Java Color class, and Java Random class.

This is the first problem set. We are still taking "baby steps" in Java, so our first programs are "baby programs".

Problem 1 (20 points): draw a house in a Java applet

In this program you will draw a simple picture of a house in a Java applet. Download the following House.html file and the House.class file to see how the program should work.

To run the demo, save these two files in the same folder, start the command prompt, type
cd C:\myfolder
(replace myfolder by your folder name), and then type
appletviewer House.html
House.class contains the bytecode, so you don't need to compile anything.

Note: If your browser has the right plug-in, then the applet will start automatically when you click on House.html, you don't need to save the demo.

What you need to do:

Problem 2 (20 points): adding random numbers

This program is a Java application. You should start by copy/pasting code from the file Add.java.

This program generates and solves a very simple arithmetic problem: if Jack picked n apples and Jill picked m, how many apples did they pick total? Each of them could pick any number of apples less than 10. The output of the program should look something like this:


Jack picked 9 apples
Jill picked 2 apples
Together they picked 11 apples
The program should give you different results every time you run it. The program must have three different integer variables:

Problem 3 (extra credit, 10 points): random rectangles.

Use file RandomRectangles.java and the source of RandomRectangles.html to create a picture that displays three random rectangles of different colors. Clicking on RandomRectangles.html shows you the demo if your browser is set up right (refreshing the page generates a new picture). Otherwise download RandomRectangles.class.
This page is a part of the course CSci 1211 at UMM.