Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ code please 24-hour time (also known in the U.S. as military time) is widely used around the world. Time is expressed as hours since

C++ code please
image text in transcribed
24-hour time (also known in the U.S. as military time) is widely used around the world. Time is expressed as hours since midnight. The day starts at 00:00, and ends at 23:59. Write a program that converts am/pm time to 24 -hour time. The input is two numbers and a string. If the input is 230pm, the output should be 14:30. If the input is 1201 am, the output should be 00:01. Hints: - Think of how each hour should be handled. 1200 am - 1259 am becomes what? 800 am becomes what? 1200 pm? 100 pm? Group the hours into cases that should be handled similarly (e.g. 100 am to 1100 am are handled the same): - Declare variables for hoursAmPm, minAmPm, and hours24. Note that minutes for 24 -hour time remain the same as for am/pm, so no extra variable is needed. - Use an if-else statement to detect each case, and set the hours24 appropriately. - When outputting hour24, check if the hour is 09 (just check for

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions