Question: Please answer using Java Language. and staying with the same format Read in a time such as 3pm and print the equivalent military hour (such
Read in a time such as 3pm and print the equivalent military hour (such as 15). Validate the input. If the input doesn't start with an integer, print: Error: Not an integer. If the number isnt between 1 and 12, print: Erron: The hour must be between 1 and 12 . If the suffixisn't "am" or "pm", print Error: The suffix must be am or pm. xainer in = new scainer (sysiteili, ail), Iif (/ your code goes here *) \{ int hour = in.nextint (); if (/ Your code goes here /) f String suffix - in.next(); if (/ * Your code goes here %/) 1. 1 Your code goes here % //Convert hour to military time system,out.print ln(hour); \} else f System.out.printin("Error: The suffix must be an or pm.")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
