Advertisement
damesova

Travelling - Java

Dec 13th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. package NestedLoops;
  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. String destination = "";
  9.  
  10.  
  11. while (true) {
  12. destination = scanner.nextLine();
  13. if (destination.equals("End")) {
  14. break;
  15. }
  16. double budget = Double.parseDouble(scanner.nextLine());
  17.  
  18. double sum = 0;
  19. while (budget > sum) {
  20. double money = Double.parseDouble(scanner.nextLine());
  21. sum += money;
  22. }
  23. System.out.println("Going to " + destination + "!");
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement