Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package NestedLoops;
- import java.util.Scanner;
- public class Travelling {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String destination = "";
- while (true) {
- destination = scanner.nextLine();
- if (destination.equals("End")) {
- break;
- }
- double budget = Double.parseDouble(scanner.nextLine());
- double sum = 0;
- while (budget > sum) {
- double money = Double.parseDouble(scanner.nextLine());
- sum += money;
- }
- System.out.println("Going to " + destination + "!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement