Chris Pollett>Old Classes>PIC 20, Winter 2000>Hw1

Winter 2000 PIC 20 HW #1

Read to 193. The program below is due in your \submit folder by Jan 19 at 5:30p.m.

The purpose of this first assignment is to get you to write a simple Java application where you get inputs from both the command line and from dialog boxes. Also it aims to get you to practice some of the control structures of Java. For this assignment you are required to write a program MeanValue.java. This program takes one command line argument which is the number n of items to be averaged over. It then pops up dialog boxes n times to get the doubles to be averaged. Finally, a message dialog box is popped up in which the message `The average is :' + your calculation of the average is printed. The average of n numbers is the result of dividing the sum of these numbers by n. You should calculate this sum as you are popping up boxes to avoid having to store any numbers. As an example, if on the command line you type:

java MeanValue 4

Then the program will pop up dialog boxes four times to get four numbers and then outputs the average. Your program should gracefully handle the case where the person failed to supply any command line arguments.

Homework 1 FAQ.

Homework 1 Solution.