Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package nestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Travelling {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String destination = scanner.nextLine();
  9.  
  10.  
  11.         int sum = 0;
  12.  
  13.         while (!destination.equals("End")) {
  14.             int minBudget = Integer.parseInt(scanner.nextLine());
  15.             while (sum < minBudget) {
  16.                 int savedMoney = Integer.parseInt(scanner.nextLine());
  17.                 sum += savedMoney;
  18.                 if (sum >= minBudget) {
  19.                     System.out.printf("Going to %s!", destination);
  20.                 }
  21.             }
  22.             System.out.println();
  23.             sum = 0;
  24.  
  25.             destination = scanner.nextLine();
  26.  
  27.         }
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement