Guest User

01. Google Searches

a guest
Oct 18th, 2019
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int days = Integer.parseInt(input.nextLine());
  7.         int usersPerDay = Integer.parseInt(input.nextLine());
  8.         double profitFromASearch = Double.parseDouble(input.nextLine());
  9.  
  10.         int words;
  11.         double profit = 0d;
  12.  
  13.         for (int index = 1; index <= usersPerDay; index++) {
  14.             words = Integer.parseInt(input.nextLine());
  15.  
  16.             if(words > 5){
  17.                 continue;
  18.             }
  19.             else if(words == 1){
  20.                 if(index % 3 != 0){
  21.                     profit += 2.0 * profitFromASearch * days;
  22.                 }
  23.                 else if(index % 3 == 0){
  24.                     profit += 6.0 * profitFromASearch * days;
  25.                 }
  26.  
  27.             }
  28.             else{
  29.                 if(index % 3 != 0){
  30.                     profit += profitFromASearch * days;
  31.                 }
  32.                 else if(index % 3 == 0){
  33.                     profit += 3.0 * profitFromASearch * days;
  34.                 }
  35.  
  36.             }
  37.         }
  38.  
  39.         System.out.printf("Total money earned for %d days: %.2f", days, profit);
  40.     }
  41. }
Add Comment
Please, Sign In to add comment