Advertisement
Guest User

Travelling

a guest
Oct 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package NestedLoopsLab;
  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.  
  9.         while (true) {
  10.             String input = scanner.nextLine();
  11.  
  12.             if (input.equals("End")) {
  13.                 break;
  14.             }
  15.  
  16.             double totalMoney = Double.parseDouble(scanner.nextLine());
  17.  
  18.             for (int sum = 0; sum < totalMoney; ) {
  19.                 double money = Double.parseDouble(scanner.nextLine());
  20.                 sum += money;
  21.  
  22.             }
  23.             System.out.println("Going to " + input + "!");
  24.         }
  25.  
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement