Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList<Integer> balance = new ArrayList<>();
- ArrayList<String> purchase = new ArrayList<>();
- System.out.println("Введите ваш бюджет на месяц: ");
- int budget = in.nextInt();
- System.out.println("У вас есть " + budget + " до конца месяца.");
- for (int i = 0; i <= budget; i--) { // circle that responds for re-entering purchase
- System.out.println("Name of Purchase And its Price: ");
- String purchName = (String) System.in.read();
- int purchPrice = in.nextInt(); // ошибка возникает тут
- System.out.println("Thanks!");
- balance.add(purchPrice);
- purchase.add(purchName);
- int value = budget - purchPrice;
- System.out.println("If you want continue write 1");
- System.out.println("See you purchase 2");
- }
- }
- Введите ваш бюджет на месяц:
- 20
- У вас есть 20 до конца месяца.
- Name of Purchase And its Price:
- qwer
- Exception in thread "main" java.util.InputMismatchException
- at java.base/java.util.Scanner.throwFor(Scanner.java:939)
- at java.base/java.util.Scanner.next(Scanner.java:1594)
- at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
- at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
- at com.begin.exampleTwo.main(exampleTwo.java:23)
- Process finished with exit code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement