Advertisement
Guest User

Untitled

a guest
Apr 26th, 2020
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Travelling {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String input = scanner.nextLine();
  8.         double savedMoney = 0;
  9.  
  10.  
  11.         while (!"End".equals(input)){
  12.             double minimalBudget = Double.parseDouble(scanner.nextLine());
  13.             while (savedMoney < minimalBudget){
  14.                 double money = Double.parseDouble(scanner.nextLine());
  15.                 savedMoney = savedMoney + money;
  16.  
  17.             }
  18.             System.out.printf("Going to %s!%n", input);
  19.             savedMoney = 0;
  20.             input = scanner.nextLine();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement