Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class lilid {
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- int age = Integer.parseInt(scan.nextLine());
- double priceOfWashingMachine = Double.parseDouble(scan.nextLine());
- int presentPrice = Integer.parseInt(scan.nextLine());
- int numberOfToys = 0;
- int savedMoney = 0;
- int moneyForBirthday = 10;
- for (int currentYear = 1; currentYear <= age; currentYear++) {
- if(currentYear % 2 == 0){
- savedMoney += (moneyForBirthday - 1);
- moneyForBirthday += 10;
- } else {
- numberOfToys++;
- }
- }
- savedMoney += numberOfToys * presentPrice;
- System.out.println((savedMoney >= priceOfWashingMachine?
- String.format("Yes! %.2f", (savedMoney - priceOfWashingMachine))
- : String.format("No! %.2f", (priceOfWashingMachine - savedMoney))));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement