Lab 6a: Tracking Sales Lab 6a: Tracking Sales File Sales6a.java contains a Java program 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. Find the average - Compute and print the average sale per person. (You can compute this directly from the total; no loop is necessary.) Find maximum sale – a. Find Max sale and associate id - Find the associate who had the maximum sale and the value of that sale b. Print Max sale and associate id - 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 need another loop for this; you can do it in the same loop where the values are read and the sum is computed. Find minimum sale - Do the same for the minimum sale. Sales goal - After the list, sum, average, max and min have been printed, a. Input a sales goal - Ask the user to enter a sales goal. b. Print ID and $$ of those that exceeded the goal - Then print the id of each salesperson who exceeded that amount, and the amount of their sales. c. Print total # of people who exceeded the goal - Print the total number of salespeople whose sales exceeded the value entered. No Salesperson with Zero for an ID - 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 resides in array location 0, and so on. Allow user to determine how many salespeople there will be - Instead of always reading in 5 sales amounts, at the beginning ask the user for the number of sales people and then create an array that is just the right size. The program can then proceed as before. 2. 3. 4. 5. 6. // **************************************************************** // Sales.java [Lab 6a] // Student Name: <name> // // Reads in and stores sales for each of 5 salespeople. Displays // sales entered by salesperson id and total sales for all salespeople. // // **************************************************************** import java.util.Scanner; public class Sales6a { public static void main( String[] args ) { final int SALESPEOPLE = 5; int[] iArrSales = new int[SALESPEOPLE]; int iSum; Scanner scan = new Scanner( System.in ); // ---------------------------------------------// TODO #6: Allow user to determine how many salespeople // there will be // ---------------------------------------------// Loop through and input sales for ( int i = 0; i < iArrSales.length; i++ ) { System.out.print( "Enter sales for salesperson " + i + ": " ); iArrSales[i] = scan.nextInt(); } // ---------------------------------------------// Loop through and output the sales System.out.println( "\nSalesperson Sales" ); System.out.println( "--------------------" ); iSum = 0; for ( int i = 0; i < iArrSales.length; i++ ) Page 1 of 2 One Dimensional Arrays Lab 6a: Tracking Sales { System.out.println( " " + i + " " + iArrSales[i] ); iSum += iArrSales[i]; // ---------------------------------------------// TODO #2a: Determine the maximum sale and the // associate's ID // ---------------------------------------------// TODO #3a: Determine the minimum sale and the // associate's ID } // ---------------------------------------------// Print the summaries System.out.println( "\nTotal sales: " + iSum ); // ---------------------------------------------// TODO #1: Print out the average // ---------------------------------------------// TODO #2b: Print out the maximum sale and the salesperson // who made it // ---------------------------------------------// TODO #3b: Print out the minimum sale and the salesperson // who made it // ---------------------------------------------// TODO #4a: Ask user to enter in a sales goal // ---------------------------------------------// TODO #4b: Print out the salesperson and // their sales when they exceeded the sales goal // ---------------------------------------------// TODO #4c: Print out the total number of people // who exceeded the sales goal } } Sample Output Enter Enter Enter Enter Enter Enter Enter the # sales sales sales sales sales sales of salespeople will be used by this program: 6 for salesperson 1: 40 for salesperson 2: 50 for salesperson 3: 45 for salesperson 4: 80 for salesperson 5: 30 for salesperson 6: 65 Salesperson Sales -------------------1 40 2 50 3 45 4 80 5 30 6 65 Total sales: 310 Average amount of sales per person: 51 Salesperson 4 had the highest sale with $80 Salesperson 5 had the highest sale with $30 Please enter in a sales goal: 50 Salesperson 4 exceeded the sales goal with $80 Salesperson 6 exceeded the sales goal with $65 2 people exceeded the sales goal. Page 2 of 2 One Dimensional Arrays