Create a function called MilitaryToRegularTime that converts time in the military time format into the regular format. For example, convert 2249 to 10:49 pm. The function should receive a single int parameter that represents the military time. It should return a std::string that contains the regular time counterpart of the given military time. Please see the sample output below to guide the design of your program

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Military to Regular Time

Create a function called MilitaryToRegularTime that converts time in the military time format into the regular format. For example, convert 2249 to 10:49 pm.

The function should receive a single int parameter that represents the military time. It should return a std::string that contains the regular time counterpart of the given military time.

Please see the sample output below to guide the design of your program.

Note: Consider possible edge cases in user input to ensure your program works correctly.

Sample output:

Please enter the time in military time: 1433 The equivalent regular time is: 2:33 pm

Make sure that you examine the MilitaryToRegularTime function prototype in time_converter.h, implement it in time_converter.cc, and call it from inside of main.cc. You'll find that skeleton code has already been provided and you simply need to call the function, which can be called from inside main.cc because we include the header file via: #include "time_converter.h"

main.cc file

#include <iostream>
  #include <string>
   
  #include "time_converter.h"
   
  int main() {
  int military_time = 0;
  std::cout << "Please enter the time in military time: ";
  std::cin >> military_time;
   
  // TODO: Call your function to convert from military time to regular time
  // and assign its result to regular_time.
  std::string regular_time;
   
  std::cout << "The equivalent regular time is: " << regular_time << "\n";
  return0;
  }

 

time_converter.cc file 

#include <iostream>
  #include <string>
   
  std::string MilitaryToRegularTime(int military_time) {
  // TODO: convert military_time to regular time in string format.
  // Hint: std::to_string() converts a given integer to a string.
  return"";
  }

 

time_converter.h file 

#include <iostream>
  #include <string>
   
  // Converts the time in military format to regular format.
  std::string MilitaryToRegularTime(int military_time);
Sample output:
Please enter the time in military time: 1433
The equivalent regular time is: 2:33 pm
Transcribed Image Text:Sample output: Please enter the time in military time: 1433 The equivalent regular time is: 2:33 pm
Military to Regular Time
Create a function called MilitaryToRegularTime that converts time in the military time format into the regular format. For example,
convert 2249 to 10:49 pm.
The function should receive a single int parameter that represents the military time. It should return a std::string that contains the
regular time counterpart of the given military time.
Please see the sample output below to guide the design of your program.
Note: Consider possible edge cases in user input to ensure your program works correctly.
Sample output:
Please enter the time in military time: 1433
The equivalent regular time is: 2:33 pm
Make sure that you examine the MilitaryToRegularTime function prototype in time_converter.h, implement it in time_converter.cc,
and call it from inside of main.cc. You'll find that skeleton code has already been provided and you simply need to call the function, which
can be called from inside main.cc because we include the header file via: #include "time_converter.h"
Transcribed Image Text:Military to Regular Time Create a function called MilitaryToRegularTime that converts time in the military time format into the regular format. For example, convert 2249 to 10:49 pm. The function should receive a single int parameter that represents the military time. It should return a std::string that contains the regular time counterpart of the given military time. Please see the sample output below to guide the design of your program. Note: Consider possible edge cases in user input to ensure your program works correctly. Sample output: Please enter the time in military time: 1433 The equivalent regular time is: 2:33 pm Make sure that you examine the MilitaryToRegularTime function prototype in time_converter.h, implement it in time_converter.cc, and call it from inside of main.cc. You'll find that skeleton code has already been provided and you simply need to call the function, which can be called from inside main.cc because we include the header file via: #include "time_converter.h"
Expert Solution
Step 1

main.cc file
#include <iostream>
   #include <string>
    
   #include "time_converter.h"
    
   int main() {
   int military_time = 0;
   std::cout << "Please enter the time in military time: ";
   std::cin >> military_time;
    
   // TODO: Call your function to convert from military time to regular time
   // and assign its result to regular_time.
   std::string regular_time;
 regular_time = MilitaryToRegularTime(military_time);
    
   std::cout << "The equivalent regular time is: " << regular_time << "\n";
   return0;
   }

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education