Advertisement
marking2112

Travelling

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