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