Edzhevit

GoogleSearches

Dec 4th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. package OldExams;
  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 numUsers = Integer.parseInt(reader.readLine());
  12.         double moneyPerSearch = Double.parseDouble(reader.readLine());
  13.  
  14.         double totalMoney = 0;
  15.  
  16.         for (int i = 1; i <= numUsers; i++) {
  17.             int wordsInRange = Integer.parseInt(reader.readLine());
  18.  
  19.             if (wordsInRange > 5){
  20.                 continue;
  21.             } else if (wordsInRange == 1){
  22.                 totalMoney += moneyPerSearch * 2;
  23.             } else {
  24.                 totalMoney += moneyPerSearch;
  25.             }
  26.             if (i == 3 || i == 6 || i == 9){
  27.                 totalMoney += moneyPerSearch * 3;
  28.             }
  29.  
  30.         }
  31.  
  32.         totalMoney *= days;
  33.  
  34.         System.out.printf("Total money earned for %d days: %.2f",days,totalMoney);
  35.     }
  36. }
Add Comment
Please, Sign In to add comment