Sasho_Cvetkov17101

umnata Lili

Jan 20th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class umnataLili {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int age = Integer.parseInt(scanner.nextLine());
  8.         double priceOfWashingMachine = scanner.nextInt();
  9.         int presentPrice = scanner.nextInt();
  10.  
  11.         int numberOfToys = 0;
  12.         int savedMoney = 0;
  13.         int moneyForBirthday = 10;
  14.  
  15.         for (int currentYear = 1; currentYear <= age; currentYear++){
  16.             if (currentYear % 2 == 0) {
  17.                 savedMoney += (moneyForBirthday - 1);
  18.                 moneyForBirthday += 10;
  19.             }else{
  20.                 numberOfToys++;
  21.             }
  22.         }
  23.         System.out.println((savedMoney >= priceOfWashingMachine ?
  24.                 String.format("Yes! %.2f",(savedMoney - priceOfWashingMachine))
  25.                 : String.format("No! %.2f", (priceOfWashingMachine - savedMoney))));
  26.     }
  27. }
  28. // 1 godini 2 cena na peralnq 3 edinichna cena na igrachka
Add Comment
Please, Sign In to add comment