Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MidExam;
- import java.util.Scanner;
- public class First {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int party = Integer.parseInt(scanner.nextLine());
- int days = Integer.parseInt(scanner.nextLine());
- ;
- int coinTotal = 0;
- for (int i = 1; i <= days; i++) {
- if (i % 15 == 0) {
- party += 5;
- }
- if (i % 10 == 0) {
- party -= 2;
- }
- if (i % 3 == 0) {
- coinTotal -= party *3;
- }
- if (i % 5 == 0) {
- coinTotal += party * 20;
- if (i % 3 == 0) {
- coinTotal -= party * 2;
- }
- }
- coinTotal += 50;
- coinTotal -= party * 2;
- }
- int coinsPerParty = coinTotal / party;
- System.out.printf("%d companions received %d coins each.", party, coinsPerParty);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement