Advertisement
Vankata17

SmartLili

Dec 10th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package dsqk;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class zdr {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scan = new Scanner(System.in);
  10.         System.out.print(" LILI AGE:  ");
  11.         int age = Integer.parseInt(scan.nextLine());
  12.         System.out.print("WASHING MACHINE PRICE:  ");
  13.         double priceW = Double.parseDouble(scan.nextLine());
  14.         System.out.print("TOY PRICE:  ");
  15.         int priceT = Integer.parseInt(scan.nextLine());
  16.  
  17.         int toysNum = 0;
  18.         int savedMoney = 0;
  19.         int birthMoney = 10;
  20.         for (int currentYear = 1; currentYear <= age; currentYear++) {
  21.             if (currentYear % 2 == 0) {
  22.                 savedMoney += birthMoney - 1;
  23.                 birthMoney += 10;
  24.             } else {
  25.                 toysNum++;
  26.             }
  27.             savedMoney += toysNum * priceT;
  28.         }
  29.  
  30.         if (savedMoney >= priceW) {
  31.             System.out.println("YES"+(savedMoney-priceW));
  32.         } else {
  33.             System.out.println("NO");
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement