Advertisement
zlatinnn

06. Travelling

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