Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FORcleverLili {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int age = Integer.parseInt(scanner.nextLine());
- double priceW = Double.parseDouble(scanner.nextLine());
- int priceT = Integer.parseInt(scanner.nextLine());
- int TOTAL = 0;
- int moneyBday = 0;
- int toys = 0;
- for (int year = 0; year < age; year++) {
- if (year % 2 == 0) {
- TOTAL += moneyBday;
- moneyBday += 10;
- } else {
- toys++;
- }
- }
- TOTAL += toys * priceT;
- TOTAL -= age / 2;
- if (TOTAL < priceW) {
- System.out.printf("No! %.2f",(priceW - TOTAL));
- } else {
- System.out.printf("Yes! %.2f",(TOTAL - priceW));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement