Advertisement
Helena12

Traveling

Nov 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Traveling {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.             while (true) {
  8.                 String destination = scanner.nextLine();
  9.  
  10.                 if (destination.equalsIgnoreCase("End")) {
  11.                     break;
  12.                 }
  13.                 double minBudget = Double.parseDouble(scanner.nextLine());
  14.                 double savings = 0;
  15.  
  16.                 while (savings < minBudget) {
  17.                     double money = Double.parseDouble(scanner.nextLine());
  18.                     savings += money;
  19.                 }
  20.                 System.out.printf("Going to %s!\n", destination);
  21.             }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement