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
The famous arcade game Space Invaders was first adapted to which home console?
spin [16.1K]

Answer:

Attari VCS 2600

Explanation:

It was in 1980 and then home gaming really took off!

7 0
2 years ago
While the names for Web addresses, or URLs, are not case-sensitive, the names for files you create for the Web are. 
gtnhenbr [62]
90% sure the answer isTrue
6 0
3 years ago
How to simplify???? 2(-3x^2+6x+1)-2(4x^2-3x+1)<br><br>​
bazaltina [42]

Distribute:

=(2)(−3x2)+(2)(6x)+(2)(1)+(−2)(4x2)+(−2)(−3x)+(−2)(1)

=−6x2+12x+2+−8x2+6x+−2

Combine Like Terms:

=−6x2+12x+2+−8x2+6x+−2

=(−6x2+−8x2)+(12x+6x)+(2+−2)

=−14x2+18x

Answer:

=−14x2+18x

8 0
3 years ago
Wireless networks are the most difficult type of network to set up <br> true or false
Elden [556K]

Answer:

The answer is "False".

Explanation:

  • Wireless networks are a network, set up to communicate between computers and other network devices using a radio signals frequency. It is also sometimes referred to as a WiFi or WLAN network. Due to the easy set-up and cabling feature, this network is now popular.  
  • A Wireless network uses a signal that is transmitted and decoded by a wireless router. The information is then sent to the internet via a wired Ethernet connection.

5 0
3 years ago
Binary Numbers and Conversion 1. Complete the following decimal-to-binary number conversions. a) 17 (10) b) 34 (10) c) 58 (10) d
GaryK [48]

Answer:

a) 10001

b)100010

c)111010

d)1111100

e)1110111

f)10110010

g)100101001

h)110011101

Explanation:

7 0
2 years ago
Other questions:
  • A teacher uses the spreadsheet below to determine the average quiz score of each student. The teacher inserts this information i
    11·2 answers
  • PLEASE HELP!!!!! MUCH OBLIGED!!!!
    15·1 answer
  • . Write a short program that asks the user to input a string, and then outputs the
    15·1 answer
  • What are the text or graphics that are lighter than the main text located in a document's background called?
    10·1 answer
  • Given the following sets, for each set operation provide the elements of the resulting set in set notation or using a well-known
    5·1 answer
  • Two-dimensional random walk (20 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of
    14·1 answer
  • Which option on the Format tab is used to modify particular portions of the chart?
    12·1 answer
  • Digital on a smart phone means the camera is actually zooming in on the photo itself not the subject that you are shooting true
    8·1 answer
  • Examples of how the development of coding changed the way we live. What type of technology was created as a result of code?
    10·1 answer
  • What are the features of the title bar for the Microsoft word application?​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!