Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String destination = scanner.nextLine();
- int budget = Integer.parseInt(scanner.nextLine());
- int sum = 0;
- while (true){
- String nextLine = scanner.nextLine();
- if(nextLine.equals("End"))
- break;
- int money = Integer.parseInt(nextLine);
- sum += money;
- if (sum >= budget) {
- System.out.printf("Going to %s!\n", destination);
- destination = scanner.nextLine();
- if(destination.equals("End"))
- break;
- budget=Integer.parseInt(scanner.nextLine());
- sum = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment