galinyotsev123

ProgBasics07Nested-Loops-P06travelling

Jan 7th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P06travelling {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String destination = scanner.nextLine();
  8.  
  9. while(!destination.equalsIgnoreCase("end")){
  10. double minBudget = Double.parseDouble(scanner.nextLine());
  11.  
  12. double saving = 0;
  13.  
  14. while (saving <minBudget){
  15. saving += Double.parseDouble(scanner.nextLine());
  16. }
  17. System.out.printf("Going to %s!%n", destination);
  18. saving -= minBudget;
  19.  
  20. destination = scanner.nextLine();
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment