I am trying to write a method name findNormalizedHour. I want it to implement the following specification: /** * Given an hour between 0 and 23 (from 24-hour format), * convert it to an hour appropriate for 12-hour format * * @precondition 0 <= hour <= 23 * @postcondition none * * @param hour the hour, in 24-hour format * @return an hour between 1 and 12, as appropriate */ The findNormalizedHour() is a method that converts from a 24-hour format to a 12-hour format. Is there anyway I could get some assistance accomplishing this?
I am trying to write a method name findNormalizedHour. I want it to implement the following specification:
/**
* Given an hour between 0 and 23 (from 24-hour format),
* convert it to an hour appropriate for 12-hour format
*
* @precondition 0 <= hour <= 23
* @postcondition none
*
* @param hour the hour, in 24-hour format
* @return an hour between 1 and 12, as appropriate
*/
The findNormalizedHour() is a method that converts from a 24-hour format to a 12-hour format. Is there anyway I could get some assistance accomplishing this?
Introduction
Midnight is 00:00:00 on a 24-hour clock and 12:00:00 on a 12-hour clock. The minutes & seconds in both observations must now be checked to ensure consistency. Only when the meridian shifts are there changes in hours.
We will first transform the supplied string of hours into such an integer before checking the hours. We will modulo the hour by 12 after converting it to an integer to create a 12-hour format.
The case in which the hour is zero will be calculated separately.
Step by step
Solved in 4 steps with 3 images