Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. ArrayList<Integer> balance = new ArrayList<>();
  2. ArrayList<String> purchase = new ArrayList<>();
  3.  
  4. System.out.println("Введите ваш бюджет на месяц: ");
  5. int budget = in.nextInt();
  6.  
  7. System.out.println("У вас есть " + budget + " до конца месяца.");
  8.  
  9. for (int i = 0; i <= budget; i--) { // circle that responds for re-entering purchase
  10. System.out.println("Name of Purchase And its Price: ");
  11.  
  12. String purchName = (String) System.in.read();
  13. int purchPrice = in.nextInt(); // ошибка возникает тут
  14.  
  15. System.out.println("Thanks!");
  16.  
  17. balance.add(purchPrice);
  18. purchase.add(purchName);
  19.  
  20. int value = budget - purchPrice;
  21.  
  22. System.out.println("If you want continue write 1");
  23. System.out.println("See you purchase 2");
  24. }
  25. }
  26.  
  27. Введите ваш бюджет на месяц:
  28. 20
  29. У вас есть 20 до конца месяца.
  30. Name of Purchase And its Price:
  31. qwer
  32. Exception in thread "main" java.util.InputMismatchException
  33. at java.base/java.util.Scanner.throwFor(Scanner.java:939)
  34. at java.base/java.util.Scanner.next(Scanner.java:1594)
  35. at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
  36. at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
  37. at com.begin.exampleTwo.main(exampleTwo.java:23)
  38.  
  39. Process finished with exit code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement