Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package yoyo;
- import java.util.Scanner;
- public class lili {
- public static void main(String[] args)
- {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Lilly's age: ");
- //godini
- int age = Integer.parseInt(scanner.nextLine());
- //cena mashina
- System.out.println("The price of Washing Machine: ");
- //cena igrachka
- double PriceWM = Double.parseDouble(scanner.nextLine());
- System.out.println("The price of 1 toy: ");
- int PriceT = Integer.parseInt(scanner.nextLine());
- //pari
- int MoneyFromBirthday = 0;
- int SavedMoney = 0;
- int Toys = 0;
- for(int year = 1; year <= age; year++){
- if(year %2 ==0){
- MoneyFromBirthday += 10;
- SavedMoney += MoneyFromBirthday - 1;
- }else{
- Toys++;
- }
- }
- SavedMoney += PriceT * Toys;
- if(SavedMoney >= PriceWM){
- System.out.printf("Yes! %.2f", SavedMoney - PriceWM);
- }else{
- System.out.printf("No! %.2f", PriceWM - SavedMoney);
- }
- scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement