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 years = Integer.parseInt(scanner.nextLine());
- double preisWascher = Double.parseDouble(scanner.nextLine());
- int priceToy = Integer.parseInt(scanner.nextLine());
- int toyCounter = 0;
- int summonney = 0;
- int counterSum = 1;
- for (int i = 1; i <= years; i++) {
- if (i % 2 == 1) {
- toyCounter ++;
- }else {
- summonney += (10 * counterSum);
- counterSum ++;
- }
- }
- int priceAllToys = toyCounter * priceToy;
- int total = priceAllToys + (summonney - counterSum);
- if (preisWascher < (total + 1)) {
- System.out.printf("Yes! %.2f", (total + 1) - preisWascher);
- }else {
- System.out.printf("No! %.2f", preisWascher - (total + 1));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement