Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class SmartLilly {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- int ageLilly = Integer.parseInt(myScan.nextLine());
- double washingMachinePrice = Double.parseDouble(myScan.nextLine());
- int toyPrice = Integer.parseInt(myScan.nextLine());
- int toysCount = 0;
- int moneyPerYear = 0;
- int moneyCollected = 0;
- int brotherMoney = 0;
- for (int i = 1; i <= ageLilly; i++) {
- if (i % 2 == 0) {
- moneyPerYear += 10;
- moneyCollected += moneyPerYear;
- brotherMoney++;
- } else {
- toysCount += 1;
- }
- }
- double totalMoney = moneyCollected + (toyPrice * toysCount) - brotherMoney;
- if (totalMoney >= washingMachinePrice) {
- double remainMoney = totalMoney - washingMachinePrice;
- System.out.printf("Yes! %.2f", remainMoney);
- } else {
- double neededMoney = washingMachinePrice - totalMoney;
- System.out.printf("No! %.2f", neededMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement