veronikaaa86

5. Пътуване

Feb 11th, 2023
1,464
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 P05Traveling {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String input = scanner.nextLine();
  10.  
  11.         while (!input.equals("End")) {
  12.             String destination = input;
  13.             double tripPrice = Double.parseDouble(scanner.nextLine());
  14.  
  15.             double currentSum = 0;
  16.             while (currentSum < tripPrice) {
  17.                 double amount = Double.parseDouble(scanner.nextLine());
  18.                 currentSum += amount;
  19.             }
  20.  
  21.             System.out.printf("Going to %s!%n", destination);
  22.  
  23.             input = scanner.nextLine();
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment