Guest User

Untitled

a guest
Apr 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. import java.util.Scanner;
  2. // ****************************************************************
  3. // Sales.java
  4. //
  5. // Reads in and stores sales for each of 5 salespeople. Displays
  6. // sales entered by salesperson id and total sales for all salespeople.
  7. //
  8. // ****************************************************************
  9. public class Sales
  10. {
  11. public static void main(String[] args)
  12. {
  13. int cha;
  14. double sum;
  15. int count = 0;
  16. Scanner Keyboard = new Scanner(System.in);
  17.  
  18.  
  19.  
  20. System.out.print("Enter Ammount of Sales People: ");
  21. cha = Keyboard.nextInt();
  22. final int SALESPEOPLE = cha;
  23. int[] sales = new int[SALESPEOPLE];
  24.  
  25.  
  26.  
  27.  
  28.  
  29. for (int i=0; i<sales.length; i++)
  30. {
  31. System.out.print("Enter sales for salesperson " + (i+1) + ": ");
  32. sales[i] = Keyboard.nextInt();
  33. }
  34.  
  35. System.out.println("\nSalesperson Sales");
  36. System.out.println("--------------------");
  37. sum = 0;
  38. for (int i=0; i<sales.length; i++)
  39. {
  40. System.out.println(" " + (i+1) + " " + sales[i]);
  41. sum += sales[i];
  42. }
  43.  
  44. System.out.println("\nTotal sales: " + sum);
  45. double hero;
  46. double finals;
  47. //find average sales
  48. sum=0;
  49. for (int noes : sales)
  50. {
  51. sum += noes;
  52. }
  53. System.out.println("Average Sales= " + (sum/SALESPEOPLE));
  54.  
  55. int fd = 1;
  56. //find max sales
  57.  
  58.  
  59. int max = sales[0];
  60. int min = sales[0];
  61. int a =1, b =1;
  62. for (int jj=0;jj<sales.length; jj++)
  63. { if(max < sales[jj])
  64. {
  65. max = sales[jj];
  66. a = jj+1;
  67. }
  68. if(min > sales[jj])
  69. {
  70. min = sales[jj];
  71. b = jj+1;
  72. }
  73. }
  74. System.out.println("Person " + a + "sold the most with " + max + " items sold." );
  75.  
  76. System.out.println("Person " + b + "sold the least with " + min + " items sold." );
  77.  
  78.  
  79.  
  80.  
  81.  
  82. // enter a number of sales and I will let you know who exceeded it
  83. System.out.println("Please enter a value and I will let you know who exceeded it: ");
  84. int non = Keyboard.nextInt();
  85.  
  86. int x=0;
  87.  
  88. for (int h=0; h<SALESPEOPLE; h++)
  89. {
  90. if (sales[h] < non)
  91. {
  92. x++;
  93. }
  94. else
  95. {
  96. System.out.println("Person " + (h+1) +" exceeded expectations" + "With " + (sales[h]) + " Items Sold");
  97. }
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. }
  125.  
  126. }
Add Comment
Please, Sign In to add comment