Advertisement
Ligh7_of_H3av3n

04. Computer Firm

Oct 15th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. package SamiqtIzpit;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.         double finalsales = 0;
  11.         double ratingcount = 0;
  12.         for (int i = 1; i <n ; i++) {
  13.             double rating = 0;
  14.             int num = Integer.parseInt(scanner.nextLine());
  15.             if (num % 10 == 2){
  16.                 rating = 0;
  17.                 ratingcount +=2;
  18.             } else if (num % 10 == 3) {
  19.                 rating = 0.5;
  20.                 ratingcount +=3;
  21.             } else if (num % 10 == 4) {
  22.                 rating = 0.7;
  23.                 ratingcount +=4;
  24.             } else if (num % 10 == 5) {
  25.                 rating = 0.85;
  26.                 ratingcount +=5;
  27.             }else {
  28.                 rating=1.0;
  29.                 ratingcount +=6;
  30.             }
  31.             String firsttwodec = "";
  32.             String numSrt = Integer.toString(num);
  33.             for (int j = 0; j <=1 ; j++) {
  34.                 char r =numSrt.charAt(j);
  35.                 String newstr = r + "";
  36.                 firsttwodec = firsttwodec + newstr;
  37.  
  38.             }
  39.             int decimal = Integer.parseInt(firsttwodec);
  40.             double sales = decimal + rating;
  41.             finalsales += sales;
  42.  
  43.         }
  44.         System.out.printf("%.2f\n", finalsales);
  45.         System.out.printf("%.2f", ratingcount /n);
  46.  
  47.  
  48.  
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement