CarmenPop

Untitled

Mar 5th, 2020
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Scanner scanner = new Scanner(System.in);
  3. String destination = scanner.nextLine();
  4. int budget = Integer.parseInt(scanner.nextLine());
  5. int sum = 0;
  6. while (true){
  7. String nextLine = scanner.nextLine();
  8. if(nextLine.equals("End"))
  9. break;
  10. int money = Integer.parseInt(nextLine);
  11. sum += money;
  12. if (sum >= budget) {
  13. System.out.printf("Going to %s!\n", destination);
  14. destination = scanner.nextLine();
  15. if(destination.equals("End"))
  16. break;
  17. budget=Integer.parseInt(scanner.nextLine());
  18. sum = 0;
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment