Helena12

Computer Firm

Dec 12th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.nio.Buffer;
  5.  
  6. public class P05AComputerFirm {
  7.     public static void main(String[] args) throws IOException {
  8.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  9.  
  10.        int computersNumber = Integer.parseInt(reader.readLine());
  11.  
  12.         double rating = 0;
  13.         double averageRating = 0;
  14.         double possibleSales = 0;
  15.  
  16.         for (int i = 1; i <= computersNumber; i++) {
  17.             double sales = Integer.parseInt(reader.readLine());
  18.  
  19.  
  20.             if (sales % 10 == 2) {
  21.                 rating += 2;
  22.                 possibleSales += 0;
  23.  
  24.             } else if (sales % 10 == 3) {
  25.                 rating += 3;
  26.                 possibleSales += Math.floor(sales / 10 * 0.50);
  27.  
  28.             } else if (sales % 10 == 4) {
  29.                 rating += 4;
  30.                 possibleSales += Math.floor(sales / 10 * 0.70);
  31.  
  32.             } else if (sales % 10 == 5) {
  33.                 rating += 5;
  34.                 possibleSales += Math.floor(sales / 10 * 0.85);
  35.  
  36.             } else if (sales % 10 == 6) {
  37.                 rating += 6;
  38.                 possibleSales += Math.floor(sales / 10);
  39.             }
  40.  
  41.             averageRating = rating / computersNumber;
  42.         }
  43.         System.out.printf("%.2f\n%.2f", possibleSales, averageRating);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment