jeffheaton's picture
Get the entire book!
Java for the Beginning Programmer

Write a program, named Assignment6, that contains two instance variables named total and itemCount. These two variables will keep track of a total and number of items.

You should provide two methods. The first method, named clear will clear the total and item count. The second method, named add, will accept numbers to be added to the total.

Finally, you will provide two functions. The first, named “getTotal” will return the total. The second, named “getAverage” will return the average.

You should test your program with the following numbers. You can test your program by calling “add” in the main method.

17
22
48
22
1
5

What is the average? What is the total?


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.