Advertisement
SIRAKOV4444

Untitled

Apr 12th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FORcleverLili {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int age = Integer.parseInt(scanner.nextLine());
  8. double priceW = Double.parseDouble(scanner.nextLine());
  9. int priceT = Integer.parseInt(scanner.nextLine());
  10.  
  11.  
  12. int TOTAL = 0;
  13. int moneyBday = 0;
  14. int toys = 0;
  15.  
  16.  
  17. for (int year = 0; year < age; year++) {
  18. if (year % 2 == 0) {
  19. TOTAL += moneyBday;
  20. moneyBday += 10;
  21. } else {
  22. toys++;
  23. }
  24. }
  25.  
  26. TOTAL += toys * priceT;
  27. TOTAL -= age / 2;
  28.  
  29.  
  30. if (TOTAL < priceW) {
  31. System.out.printf("No! %.2f",(priceW - TOTAL));
  32. } else {
  33. System.out.printf("Yes! %.2f",(TOTAL - priceW));
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement