Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nestedLoops;
- import java.util.Scanner;
- public class P05Traveling {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- while (!input.equals("End")) {
- String destination = input;
- double tripPrice = Double.parseDouble(scanner.nextLine());
- double currentSum = 0;
- while (currentSum < tripPrice) {
- double amount = Double.parseDouble(scanner.nextLine());
- currentSum += amount;
- }
- System.out.printf("Going to %s!%n", destination);
- input = scanner.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment