BapBapuHa

Clever Lily

Feb 1st, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         int age = Integer.parseInt(scanner.nextLine());
  10.         double washingMachine = Double.parseDouble(scanner.nextLine());
  11.         int cost = Integer.parseInt(scanner.nextLine());
  12.         int toy = 0;
  13.         int money = 0;
  14.         int a = 1;
  15.         for (int i = 1; i <= age; i++) {
  16.             if (i % 2 == 0) {
  17.                 money += a * 10;
  18.                 money--;
  19.                 a++;
  20.             } else {
  21.                 toy++;
  22.             }
  23.         }
  24.         money = money + toy * cost;
  25.         if (money >= washingMachine) {
  26.             System.out.printf("Yes! %.2f", (money - washingMachine));
  27.         } else {
  28.             System.out.printf("No! %.2f", (washingMachine - money));
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment