Advertisement
porteno

y_q5

Dec 7th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Q5 {
  4.  
  5. public static void main(String[] args) {
  6. int up_hours = 0, down_hours = 0;
  7. int up_min = 0, down_min = 0;
  8. int total_hour = 0, total_min = 0;
  9. Scanner s = new Scanner(System.in);
  10. System.out.println("enter take-off hour: ");
  11. up_hours = s.nextInt();
  12. System.out.println("enter take-off minutes: ");
  13. up_min = s.nextInt();
  14. System.out.println("enter landing hour: ");
  15. down_hours = s.nextInt();
  16. System.out.println("enter landing minutes: ");
  17. down_min = s.nextInt();
  18.  
  19. total_hour = down_hours - up_hours;
  20. if(total_hour==0)
  21. total_min = up_min + down_min;
  22. else {
  23. total_min = 60 - up_min + down_min;
  24. if(total_min>60) {
  25. total_hour++;
  26. total_min = total_min - 60;
  27. }
  28. }
  29. System.out.println("the flight takes "+total_hour+" hours and "+total_min+" minutes");
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement