Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CSE 110 Lab 10: Arrays LabExercise: Complete this portion of the lab during your

ID: 3808530 • Letter: C

Question

CSE 110 Lab 10: Arrays LabExercise: Complete this portion of the lab during your labsession Tracking Sales The file Lab10java contains a Java program that prompts for and reads in the sales for each of 5 salespeople in a company. It then prints out each salesperson's ID, each salesperson's amount of sales, and the total sales across all salespeople. Take a look at the code to figure out how it's structured and what it's up to. Now modify and improve the program as follows: 1. Compute and print the average sale amount. 2. 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 S4500. 3. Do the same for the minimum sale. [Your Name Here) (Your Lab Letter Here Lab10 .java 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: import java .text. Number Format public class Lab10 public static void main (Stringt args) Number Format money Number Format.getcurrency Instance o variables and constants needed for the progran final int SALESPEOPLE new double tsALESPECPIE); sales double Declare additional variables to store the nax min sale index Don't forget to initialize the max and nin index to 01 Scanner scan new Scanner (systen. in) Read in each person's sales for (int i 0: 1

Explanation / Answer

package animat;

import java.text.NumberFormat;
import java.util.Scanner;

class lab10
{
  
   public static void main(String args[])
   {
      
       NumberFormat money=NumberFormat.getCurrencyInstance();
       final int SALESPEOPLE=5;
      
       double sales[]=new double[SALESPEOPLE];
      
       Scanner scan=new Scanner(System.in);
       double sum=0;
       int minindex=0;
       int maxindex=0;
      
      
       for(int i=0;i<sales.length;i++)
       {
           System.out.println("enter sales for salesperson :"+i);
       sales[i]=scan.nextDouble();
      
       }
      
       System.out.println(" Salesperson Sales");
       System.out.println("------------------------");
      
      
       for(int i=0;i<sales.length;i++)
       {
       System.out.println(" "+i+" "+money.format(sales[i]));
       sum += sales[i];
      
       if(sales[minindex]>sales[i])
       {
           minindex=i;
       }
      
       if(sales[maxindex]<sales[i])
       {
           maxindex=i;
       }
      
      
       }
      
       System.out.println(" Total Sales :"+money.format(sum));
       System.out.println("Averagel Sales :"+money.format(sum/sales.length));
       System.out.println("sales person "+maxindex+" had highest sales with "+money.format(sales[maxindex]));
       System.out.println("sales person "+minindex+" had highest sales with "+money.format(sales[min`index]));

   }
}