Computers and Technology

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);
}
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, brainbean
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
image
Computers and Technology, 23.06.2019 18:40, brooklyn4932
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
image
Computers and Technology, 24.06.2019 00:00, miguelturner
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
image
Computers and Technology, 25.06.2019 04:30, greenbyron88
You can fit more raw files on a memory card than the jpeg files? truefalse
Answers: 1
Do you know the correct answer?
File sales. java contains a java program that prompts for and reads in the sales for each of 5 sales...

Questions in other subjects:

Konu
History, 13.09.2019 04:20