Question: JAVA Question - How to call this function/module in the main. I am trying to figure out how to call this code module/function in the

JAVA Question - How to call this function/module in the main.

I am trying to figure out how to call this code module/function in the main. And that the input validation for the military time is accurate. Please keep it simple, I am just starting to learn Java and am hoping I am on the right track with this.

Thank you so much!!

-----

OR - Could you please tell me how to collect integers with zeros in the front, when I just try to do integer collection the java gives an error "The literal xyz of type int is out of range", so that would be also helpful.

I created this global identifier in the class:

private static CharSequence CharSequence;

I did try using this code in the main to call the function/module, what happens is that it is accepting the input of military time but does not prompt or ask for it. Only advises if the input is wrong.

CharSequence arrival = gtArvl ("Input arrival time: ");

Goal of this function/module

I am trying to get the user to input military time for their arrival time "arvTim". They will also have to do this again for their departure time, so I will make a duplicate or second for departure time. I am not sure how to call this. Can I call this? Is the collection keyboard.nextLine() correct for the gathering of this information? Also the second part of the function/module is to do input validation. Finally, once arrival time and departure time are collected is it possible to subtract the two to determine the number of mins?

Module Example Code

public static CharSequence gtArvl(CharSequence arvTim) { arvTim = keyboard.nextLine(); try { DateTimeFormatter.ofPattern("HH:mm").parse(arvTim); } catch (DateTimeParseException e) { System.out.println(arvTim + " is not valid format."); } return arvTim; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!