Advertisement
Kathy2905

CleverLily

Oct 15th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CleverLily {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int years = Integer.parseInt(scanner.nextLine());
  8.         double preisWascher = Double.parseDouble(scanner.nextLine());
  9.         int priceToy = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int toyCounter = 0;
  12.         int summonney = 0;
  13.         int counterSum = 1;
  14.  
  15.         for (int i = 1; i <= years; i++) {
  16.             if (i % 2 == 1) {
  17.                 toyCounter ++;
  18.             }else {
  19.                 summonney += (10 * counterSum);
  20.                 counterSum ++;
  21.  
  22.             }
  23.         }
  24.         int priceAllToys = toyCounter * priceToy;
  25.         int total = priceAllToys + (summonney - counterSum);
  26.         if (preisWascher < (total + 1)) {
  27.             System.out.printf("Yes! %.2f", (total + 1) - preisWascher);
  28.         }else {
  29.             System.out.printf("No! %.2f", preisWascher - (total + 1));
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement