Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dsqk;
- import java.util.Scanner;
- public class zdr {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.print(" LILI AGE: ");
- int age = Integer.parseInt(scan.nextLine());
- System.out.print("WASHING MACHINE PRICE: ");
- double priceW = Double.parseDouble(scan.nextLine());
- System.out.print("TOY PRICE: ");
- int priceT = Integer.parseInt(scan.nextLine());
- int toysNum = 0;
- int savedMoney = 0;
- int birthMoney = 10;
- for (int currentYear = 1; currentYear <= age; currentYear++) {
- if (currentYear % 2 == 0) {
- savedMoney += birthMoney - 1;
- birthMoney += 10;
- } else {
- toysNum++;
- }
- savedMoney += toysNum * priceT;
- }
- if (savedMoney >= priceW) {
- System.out.println("YES"+(savedMoney-priceW));
- } else {
- System.out.println("NO");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement