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 money = 0;
- int toy = 0;
- int counter = 0;
- double total = 0;
- for (int year = 0; year < age; year++) {
- if (year % 2 == 0) {
- counter++;
- money = money + (10 * counter);
- } else {
- toy++;
- }
- }
- total = money + (priceT * toy) - counter * 1.0;
- if (total >= priceW) {
- System.out.printf("Yes! %.2f", total - priceW);
- } else {
- System.out.printf("No! %.2f", priceW - total);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement