Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SmartLily {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int age = Integer.parseInt(scan.nextLine());
- double washingMachinePrice = Double.parseDouble(scan.nextLine());
- int toyPrice = Integer.parseInt(scan.nextLine());
- double money = 0;
- int toysCount = 0;
- int moneyGift = 0;
- for (int i = 1; i <= age; i++) {
- if(i % 2 == 0){
- moneyGift += 10;
- money += moneyGift - 1;
- }
- else{
- toysCount++;
- }
- }
- money += toysCount * toyPrice;
- double reminder = Math.abs(money - washingMachinePrice);
- if(money >= washingMachinePrice){
- System.out.printf("Yes! %.2f", reminder);
- }
- else{
- System.out.printf("No! %.2f", reminder);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement