Advertisement
yovkovbpfps

Nested Loops Exercise Travelling

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