Advertisement
SIRAKOV4444

Untitled

Apr 12th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 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. int money = 0;
  12. int toy = 0;
  13. int counter = 0;
  14. double total = 0;
  15.  
  16.  
  17. for (int year = 0; year < age; year++) {
  18. if (year % 2 == 0) {
  19. counter++;
  20. money = money + (10 * counter);
  21. } else {
  22. toy++;
  23. }
  24. }
  25. total = money + (priceT * toy) - counter * 1.0;
  26. if (total >= priceW) {
  27. System.out.printf("Yes! %.2f", total - priceW);
  28. } else {
  29. System.out.printf("No! %.2f", priceW - total);
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement