emodev

Untitled

Dec 9th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. package a_examPreparation1;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. public class GoogleSearches {
  8.     public static void main(String[] args) throws IOException {
  9.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  10.         int days = Integer.parseInt(reader.readLine());
  11.         int usersCountPerDay = Integer.parseInt(reader.readLine());
  12.         double moneyPerSearch = Double.parseDouble(reader.readLine());
  13.  
  14.  
  15.         double allMoney = 0;
  16.         for (int i = 1; i <= usersCountPerDay; i++) {
  17.             boolean exclusion = false;
  18.             int words = Integer.parseInt(reader.readLine());
  19.             if (words > 5) {
  20.                 continue;
  21.             }
  22.             if (words == 1) {
  23.                 if (i % 3 == 0) {
  24.                     exclusion = true;
  25.                     allMoney += (moneyPerSearch * 2)* 3;
  26.                 } else {
  27.                     exclusion = true;
  28.                     allMoney +=moneyPerSearch *  2;
  29.                 }
  30.             } else {
  31.                 if (i % 3 == 0) {
  32.                     exclusion = true;
  33.                     allMoney += moneyPerSearch * 3;
  34.                 } else {
  35.                     allMoney += moneyPerSearch;
  36.                 }
  37.             }
  38.  
  39.  
  40.         }
  41.  
  42.         double result = allMoney * days;
  43.         System.out.printf("Total money earned for %d days: %.2f", days, result);
  44.  
  45.  
  46.     }
  47. }
Add Comment
Please, Sign In to add comment