: I'm a freshman in college and new to java. I am completely lost and really need help with a current assignment. Here are the instructions given by my teacher...
: 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. Files Main.java and Sales.java can be found here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Main.java
: and here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Sales.java
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. (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
: 2. (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.
: 3. (2 pts) Do the same for the minimum sale.
: 4. (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.
: 5. (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.
: 6. (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:
: 1. at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
: 2. 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.
: 7. (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.
: I'm not asking for someone to do this assignment for me...I'm just hoping there is someone out there patient and kind enough to maybe give me a step by step of what to do or how to get started, because I am completely lost from the beginning of #1 in the instructions.
: Any help would be much appreciated! Thank you!
Hint for all these assignments: first do them on paper by hand. You should notice loops and simple if-statements.
1) First you need to know how to calculate the average by hand. Since the program already provides you with the total sales and number of sales persons, you can easily calculate the average.
2&3) Pick the first sale as maximum. Then loop through the rest and check if that sale is higher. If it is, then that becomes the highest sale.
4) This is quite similar to 2&3, except that the checked value isn't the first sale, but an entry of the user. The output is also slightly different. Since you're also asked for the number of salespersons, keep a counter.
5) Subtract 1 from all the indexes, when referencing an array.
6) Prompt should be simple enough. Argument: add a constructor with 1 int argument. In that set the length of the array. In the main() check the length of the args array, and construct a Sales class with either constructor. To convert a String to an int see Integer class in JavaDoc.