CSCI 111 LAB 6
previously CSCI 15a
Lab Times: See course home page
TA: See course home page
Worth:25 points
Building on provided code:
Loops and Arrays
Tracking Sales
Files Main.java and Sales.java contain a Java application that prompts for and reads in the sales for each of 5 salespeople in a company. It then prints out the id and amount of sales for each salesperson and the total sales. Study the code, then compile and run the program to see how it works. Now modify the program as follows:
- (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
- (2 pts) Find and print the maximum sale. Print both the id of the salesperson with the max sale and the amount of the sale, e.g., "Salesperson 3 had the highest sale with $4500." Note that you don't necessarily need another loop for this; you can get it in the same loop where the values are read and the sum is computed.
- (2 pts) Do the same for the minimum sale.
- (6 pts) After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
- (2 pts) The salespeople are objecting to having an id of 0-no one wants that designation. Modify your program so that the ids run from 1-5 instead of 0-4. Do not modify the array-just make the information for salesperson 1 reside in array location 0, and so on.
- (8 pts) Instead of always reading in 5 sales amounts, allow the user to provide the number of sales people and then create an array that is just the right size.
The program can then proceed as before. You should do this two ways:
- at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
-
you should also allow the user
to input this as a program argument (which indicates a new Constructor and hence changes to both Main and Sales). You may want to see some notes. ( example)
- (4 pts) Create javadocs and an object model for the lab
You should organize your code so that it is easily readable and provides appropriate methods for appropriate tasks. Generally, variables
should have local (method) scope if not needed by multiple methods. If many methods need a variable, it should be an Instance Variable so
you do not have to pass it around to methods.
You must create the working application and a web page to provide the applications information (i.e., a page with links to the
source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this.
Submission:
- On Campus Go to your Vista page for this course, and to the Assignments link.
Go to the
Lab Assignments: drop box link and then to lab 6 and follow directions for submission.
Obviously you need to provide us the link to your web page, or we will not know
where to find your page for grading. (Some of you have been forgetting to provide the link and hence have no grade for some of your labs.)
- Distance/Web students
Submit your lab by going to http://www.ecst.csuchico.edu/~amk/foo/csci111/turnin/
Web Page Submission Required Contents:
In the URL you submit, you should have a web page that
- provides links to source code,
- a link to
the javadoc created page, and
- link to the Object Model.
Poorly designed (eg. everything in one big multi-purpose method) and poorly documented source code will also lose points.
EXTRA CREDIT: Create a GUI for the program (input and output). You can do this either as an applet or an application.
You must have a working lab following above specs to get extra points. So, do the specified lab before trying the extra.