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, 22.06.2019 09:40
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
question
Computers and Technology, 23.06.2019 03:00
What are the different parts of computer
Answers: 2
question
Computers and Technology, 23.06.2019 11:30
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
question
Computers and Technology, 23.06.2019 21:40
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings. for each match, add one point to user_score. upon a mismatch, end the game. sample output with inputs: 'rrgbryybgy' 'rrgbbrybgy'
Answers: 3
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
Physics, 05.01.2021 01:00
Questions on the website: 13722367