Advertisement
Ivakis

Умната Лили

Aug 26th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class demo {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int age = Integer.parseInt(scanner.nextLine());
  9. double washingmashine = Double.parseDouble(scanner.nextLine());
  10. int toysPrice = Integer.parseInt(scanner.nextLine());
  11.  
  12. int toysCount = 0;
  13. int moneyTotal = 0;
  14. int addedMoney = 10;
  15. int moneyCount = 0;
  16.  
  17. for (int i = 1; i <= age; i++) {
  18.  
  19. if(i % 2 == 0){
  20. moneyCount++;
  21. moneyTotal += moneyCount * 10;
  22. }else{
  23. toysCount++;
  24. }
  25. }
  26.  
  27. int moneyLeft = moneyTotal + toysCount * toysPrice - moneyCount;
  28.  
  29. if(washingmashine > moneyLeft){
  30. double result = washingmashine - moneyLeft;
  31. System.out.printf("No! %.2f",result );
  32. }else{
  33. double result = moneyLeft - washingmashine;
  34. System.out.printf("Yes! %.2f",result );;
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement