Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- // ****************************************************************
- // Sales.java
- //
- // Reads in and stores sales for each of 5 salespeople. Displays
- // sales entered by salesperson id and total sales for all salespeople.
- //
- // ****************************************************************
- public class Sales
- {
- public static void main(String[] args)
- {
- int cha;
- double sum;
- int count = 0;
- Scanner Keyboard = new Scanner(System.in);
- System.out.print("Enter Ammount of Sales People: ");
- cha = Keyboard.nextInt();
- final int SALESPEOPLE = cha;
- int[] sales = new int[SALESPEOPLE];
- for (int i=0; i<sales.length; i++)
- {
- System.out.print("Enter sales for salesperson " + (i+1) + ": ");
- sales[i] = Keyboard.nextInt();
- }
- System.out.println("\nSalesperson Sales");
- System.out.println("--------------------");
- sum = 0;
- for (int i=0; i<sales.length; i++)
- {
- System.out.println(" " + (i+1) + " " + sales[i]);
- sum += sales[i];
- }
- System.out.println("\nTotal sales: " + sum);
- double hero;
- double finals;
- //find average sales
- sum=0;
- for (int noes : sales)
- {
- sum += noes;
- }
- System.out.println("Average Sales= " + (sum/SALESPEOPLE));
- int fd = 1;
- //find max sales
- int max = sales[0];
- int min = sales[0];
- int a =1, b =1;
- for (int jj=0;jj<sales.length; jj++)
- { if(max < sales[jj])
- {
- max = sales[jj];
- a = jj+1;
- }
- if(min > sales[jj])
- {
- min = sales[jj];
- b = jj+1;
- }
- }
- System.out.println("Person " + a + "sold the most with " + max + " items sold." );
- System.out.println("Person " + b + "sold the least with " + min + " items sold." );
- // enter a number of sales and I will let you know who exceeded it
- System.out.println("Please enter a value and I will let you know who exceeded it: ");
- int non = Keyboard.nextInt();
- int x=0;
- for (int h=0; h<SALESPEOPLE; h++)
- {
- if (sales[h] < non)
- {
- x++;
- }
- else
- {
- System.out.println("Person " + (h+1) +" exceeded expectations" + "With " + (sales[h]) + " Items Sold");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment