Advertisement
N_Damyanov

01. Party Profit

Dec 17th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package MidExam;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class First {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int party = Integer.parseInt(scanner.nextLine());
  10.         int days = Integer.parseInt(scanner.nextLine());
  11.  
  12.         ;
  13.         int coinTotal = 0;
  14.         for (int i = 1; i <= days; i++) {
  15.  
  16.             if (i % 15 == 0) {
  17.                 party += 5;
  18.             }
  19.             if (i % 10 == 0) {
  20.                 party -= 2;
  21.             }
  22.             if (i % 3 == 0) {
  23.                 coinTotal -= party *3;
  24.             }
  25.             if (i % 5 == 0) {
  26.                 coinTotal += party * 20;
  27.                 if (i % 3 == 0) {
  28.                     coinTotal -= party * 2;
  29.                 }
  30.             }
  31.             coinTotal += 50;
  32.             coinTotal -= party * 2;
  33.         }
  34.         int coinsPerParty = coinTotal / party;
  35.         System.out.printf("%d companions received %d coins each.", party, coinsPerParty);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement