Advertisement
GabrielHr00

05. Travelling

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