Advertisement
myrdok123

05. Travelling

Apr 13th, 2024
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. package NestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05Travelling {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String destination = scanner.nextLine();
  10.  
  11.         while (!destination.equals("End")){
  12.             double neededMoney = Double.parseDouble(scanner.nextLine());
  13.  
  14.             double savedMoney = 0;
  15.             while (neededMoney > savedMoney){
  16.                 double currentMoney = Double.parseDouble(scanner.nextLine());
  17.                 savedMoney += currentMoney;
  18.             }
  19.  
  20.             System.out.printf("Going to %s!%n", destination);
  21.  
  22.             destination = scanner.nextLine();
  23.         }
  24.  
  25.  
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement