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