Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- 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 cost = Integer.parseInt(scanner.nextLine());
- int toy = 0;
- int money = 0;
- int a = 1;
- for (int i = 1; i <= age; i++) {
- if (i % 2 == 0) {
- money += a * 10;
- money--;
- a++;
- } else {
- toy++;
- }
- }
- money = money + toy * cost;
- if (money >= washingMachine) {
- System.out.printf("Yes! %.2f", (money - washingMachine));
- } else {
- System.out.printf("No! %.2f", (washingMachine - money));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment