Westonci.ca is the best place to get answers to your questions, provided by a community of experienced and knowledgeable experts. Connect with a community of experts ready to help you find accurate solutions to your questions quickly and efficiently. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.

. Create a java File call Sales.Java contains a Java program that prompts for 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 sale. 2. Compute and print the average sale. 3. Find and print the maximum and minimum sale. 4. 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. Instead of always reading in 5 sales amounts, in 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

Sagot :

Answer:

The program is as follows:

import java.util.*;

public class Sales{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int salesPeople;

 System.out.print("Number of Sales People: ");

 salesPeople = input.nextInt();

 int[] salesID = new int[salesPeople];

 float[] salesAmount = new float[salesPeople];

 float total = 0;

 for(int i = 0; i<salesPeople;i++){

     System.out.print("ID: ");      salesID[i] = input.nextInt();

     System.out.print("Amount: ");      salesAmount[i] = input.nextFloat();

     total+=salesAmount[i];  }

 System.out.println("ID\t\tAmount");

 for(int i = 0; i<salesPeople;i++){

     System.out.println(salesID[i]+"\t\t"+salesAmount[i]);  }

 System.out.println("Total Sales: "+total);

 System.out.println("Average Sales: "+total/salesPeople);

 Arrays.sort(salesAmount);

 System.out.println("Minimum Sales: "+salesAmount[0]);

 System.out.println("Maximum Sales: "+salesAmount[salesPeople-1]);

 float sales;

 System.out.print("Print records that exceed: ");      sales = input.nextFloat();

 System.out.println("\nID\t\tAmount");

 int count = 0;

 for(int i = 0; i<salesPeople;i++){

     if(salesAmount[i]>sales){

         System.out.println(salesID[i]+"\t\t"+salesAmount[i]);

         count++;      }  }

 System.out.print("Total sales records that exceed "+sales+" are: "+count);

}

}

Explanation:

See attachment for program source file where comments are used as explanation

View image MrRoyal