1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Flauer [41]
3 years ago
8

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);
}
}
Computers and Technology
1 answer:
myrzilka [38]3 years ago
8 0

Answer:

import java.util.Scanner;

public class Sales

{

public static void main(String[] args) {

   

    int sum;

    Scanner input = new Scanner(System.in);

   

    System.out.print("Enter number of salespeople: ");

    int salespeople = input.nextInt();

    int[] sales = new int[salespeople];

       

    for (int i=0; i<sales.length; i++)

    {

     System.out.print("Enter sales for salesperson " + (i+1) + ": ");

     sales[i] = input.nextInt();

    }

    System.out.println("\nSalesperson   Sales");

    System.out.println("--------------------");

    sum = 0;

       int maxSale = sales[0];

       int minSale  = sales[0];

       int minId=1;

       int maxId=1;

    for (int i=0; i<sales.length; i++)

    {

               System.out.println("     " + (i+1) + "         " + sales[i]);

 sum += sales[i];

  if(maxSale < sales[i])

           {

               maxSale = sales[i];

               maxId = i+1;

           }

           if(minSale > sales[i])

           {

               minSale = sales[i];

               minId = i+1;

           }

   }

System.out.println("Total sales: " + sum);

       System.out.println("The average sale is: " + sum / salespeople );

       System.out.println("Salesperson "+ maxId + " had the highest sale with "+ maxSale + ".");

       System.out.println("Salesperson "+ minId + " had the lowest sale with "+ minSale + ".");

       

       int amount = 0;

       int counter = 0;

       System.out.print("Enter an amount: ");

       amount = input.nextInt();

       for (int i=0; i<sales.length; i++)

    {

     if(sales[i] > amount) {

         counter++;

         System.out.println("Salesperson "+ (i+1) + " exceeded given amount. (Number of sales: " + sales[i] +")");

     }

    }

       System.out.println("Number of salespeople exceeded given amount is: "+ counter);

}

}

Explanation:

- Ask the user for the number of salesperson

- According to entered number, create an array called sales to hold sale number for each person

- In the first for loop, assign the given sales numbers

-  In the second for loop, print all the sales people with sales, calculate the total sales. Also, find the minimum and maximum sales numbers with associated individuals.

- Print total, average, highest, and lowest sales.

- Ask user enter an amount

- In the third for loop, find the sales people who exceeded this amount.

- Print number of sales people who exceeded the amount.

You might be interested in
Which statement best describes the computers all around us?
Advocard [28]

Answer:

B

Explanation:

we are in a digital generation, where by technology is gradually taking over the world. Almost all business, schools, company, etc make use of computer.

8 0
1 year ago
What does the proofreading mark "..." mean?
scZoUnD [109]

Answer:

I believe "..." means that you need to go further in depth with your writing.

3 0
3 years ago
Read 2 more answers
Which of the following sentences use the subjunctive mood correctly?Check all that apply. a. Dr. Franklin wishes he were the one
vredina [299]

Answer:

a. Dr. Franklin wishes he were the one who had invented the new web application.

b. If he were willing to submit the proposal, we might win the bid.

Explanation:

The subjunctive mood is when we're talking about wishes, doubts, and possibilities, in this case, we have two examples, where Dr. Franklin wishes to invent the new web application, and the other sentence is a possibility because he believes that they can win the bid. The last example is an affirmation.

4 0
3 years ago
A media company that has separate, autonomous companies for movies, tv, internet, and print journalism is most likely a ________
Llana [10]
The answer that completes the blank provided above is the term DIVISIONAL. It is most likely that a divisional structure is being utilized when a media company comprises of a separate and autonomous companies for print journalism, tv, movies and the internet.
6 0
3 years ago
What is a shell programming? Write a shell program to get the following details from the student: NAME, AGE, USN and GENDER. Out
Leya [2.2K]

Shell programs are computer programs designed to run on the Unix/Linux shell

The shell program where comments are used to explain each line is as follows:

#This gets input for NAME

read NAME  

#This gets input for AGE

read AGE  

#This gets input for USN

read USN

#This gets input for GENDER

read GENDER

#This prints the name

echo "Name: $NAME"

#This prints the age

echo "Age: AGE"

#This prints the usn

echo "USN: USN"

#This prints the gender

echo "GENDER: $GENDER"

#The following if condition determines, if the user is eligible to vote or not

if [ $USN -gt 50 ] then

echo "You are not eligible"

else

echo "You are eligible"

Read more about computer programs at:

brainly.com/question/13795586

3 0
2 years ago
Other questions:
  • At the dsl local carrier's office, the __________ demultiplexes the data streams and converts them into digital data.
    10·1 answer
  • You can install several printers on your machine, but at least one must be the _______ printer.
    6·1 answer
  • List two ways that search engines and electronic databases are similar and three ways that search engines and electronic databas
    13·2 answers
  • 1.) what is the minimum number of bits required to represent -3,997 using 2's complement form?
    6·1 answer
  • Can you redact this image
    15·1 answer
  • You work on the marketing team for a software company. You do not work closely with the development team; however, you need to k
    8·1 answer
  • Which magazine introduced the first microcomputer kit for the mits altair in its january 1975 issue?
    8·1 answer
  • Some people recommend deleting social media accounts because of the troubling legal and ethical implications of social media. Do
    9·1 answer
  • What was the worlds first coding language
    15·2 answers
  • Write the translator of third generation language​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!