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