subject

File sales. 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. compute and print the average sale. (you can compute this directly from the total; no loop is necessary.)
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 $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.
3. do the same for the 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. 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. instead of always reading in 5 sales amounts, at the beginning ask the user for the number of salespeople and then create an array that is just the right size. the program can then proceed as before.

//
// sales. 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;
public class sales
{
public static void main(string[] args)
{
final int salespeople = 5;
int[] sales = new int[salespeople];
int sum;
scanner scan = new scanner(system. in);
for (int i=0; i {
system. out. print("enter sales for salesperson " + i + ": ");
sales[i] = scan. nextint();
}
system. out. println("\nsalesperson sales");
system. out. println(" ");
sum = 0;
for (int i=0; i {
system. out. println(" " + i + " " + sales[i]);
sum += sales[i];
}
system. out. println("\ntotal sales: " + sum);
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:00
Let r be a robotic arm with a fixed base and seven links. the last joint of r is a prismatic joint, the other ones are revolute joints. give a set of parameters that determines a placement of r. what is the dimension of the configuration space resulting from your choice of parameters?
Answers: 3
question
Computers and Technology, 23.06.2019 15:30
Hey so i was just trying out some game hacks so i took a paste from online and built it in my visual studio and then suddenly my computer was working or clicking on stuff on its own am i hacked?
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
How do you know if the website is secure if you make a purchase
Answers: 2
question
Computers and Technology, 25.06.2019 05:10
Maia notices that her paragraphs are too close to one another. she wants to increase this space. which arrangement of steps does maia follow after she goes to the paragraph command group in the ribbon? type in the space needed, go to the after menu, go to the spacing part of the box, and open the paragraph dialog box. go to the spacing part of the box, go to the after menu, open the paragraph dialog box, and type in the space needed. open the paragraph dialog box, go to the spacing part of the box, go to the after menu, and type in the space needed. type in the space needed, open the paragraph dialog box, go to the after menu, and go to the spacing part of the box.
Answers: 1
You know the right answer?
File sales. java contains a java program that prompts for and reads in the sales for each of 5 sales...
Questions
question
Mathematics, 26.05.2021 17:50
question
Mathematics, 26.05.2021 17:50