Advertisement
YoannaSt173

lilineeumna

Jan 20th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. package yoyo;
  2.  
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class lili {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner scanner = new Scanner(System.in);
  12.        
  13.         System.out.println("Lilly's age: ");
  14.         //godini
  15.         int age = Integer.parseInt(scanner.nextLine());
  16.         //cena mashina
  17.         System.out.println("The price of Washing Machine: ");
  18.        
  19.         //cena igrachka
  20.         double PriceWM = Double.parseDouble(scanner.nextLine());
  21.        
  22.         System.out.println("The price of 1 toy: ");
  23.         int PriceT = Integer.parseInt(scanner.nextLine());
  24.  
  25.         //pari
  26.         int MoneyFromBirthday = 0;
  27.         int SavedMoney = 0;
  28.         int Toys = 0;
  29.  
  30.         for(int year = 1; year <= age; year++){
  31.             if(year %2 ==0){
  32.                 MoneyFromBirthday += 10;
  33.                 SavedMoney += MoneyFromBirthday - 1;
  34.                
  35.             }else{
  36.                
  37.                 Toys++;
  38.             }
  39.         }
  40.        
  41.         SavedMoney += PriceT * Toys;
  42.         if(SavedMoney >= PriceWM){
  43.             System.out.printf("Yes! %.2f", SavedMoney - PriceWM);
  44.            
  45.         }else{
  46.            
  47.             System.out.printf("No! %.2f", PriceWM - SavedMoney);
  48.            
  49.         }
  50.         scanner.close();
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement