1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olga nikolaevna [1]
3 years ago
11

Reference Parameters (returning multiple values): Write a C++ function that converts standard time to military time. Inputs incl

ude hours and minutes in standard time and a character equal to ‘a’ for am or ‘p’ for pm.
The function call might look like:

MilitaryTime(SHour, SMin, AorP, MHour, MMin);

Also write a main program to prompt the user for the inputs (such as 1:30 am), call the function, and display the input and the output in the following form:

12:30 am= 0030
2:30 am = 0230
3:30 pm = 1530
12:00 am = 0000

Run the program for the four cases above plus at least three other cases.

Hint: Using fill(’0’) is an easy way to show leading zeros.

Engineering
1 answer:
valkas [14]3 years ago
5 0

Answer:

Code is given as below:

Explanation:

#include <iostream>

using namespace std;

//function prototype declaration

void MilitaryTime(int, int, char, int &, int &);

int main()

{

    //declare required variables

    int SHour, SMin, MHour, MMin;

    char AorP;

    //promt and read the hours from the user

    cout<<"Enter hours in standard time : ";

    cin>>SHour;

    //check the hours are valid are not

    while(SHour<0 || SHour>12)

    {

         cout<<"Invalid hours for standard time. "

             <<"Try again..."<<endl;

         cout<<"Enter hours in standard time : ";

         cin>>SHour;

    }

    //promt and read the minutes from the user

    cout<<"Enter minutes in standard time : ";

    cin>>SMin;

    //check the minutes are valid are not

    while(SMin<0 || SMin>59)

    {

         cout<<"Invalid minutes for standard time. "

             <<"Try again..."<<endl;

         cout<<"Enter minutes in standard time : ";

         cin>>SMin;

    }

    //promt and read the am or pm from the user

    cout<<"Enter standard time meridiem (a for AM p for PM): ";

    cin>>AorP;

    //check the meridiem is valid are not

    while(!(AorP=='a' || AorP=='p' || AorP=='A' || AorP=='P'))

    {

         cout<<"Invalid meridiem for standard time. "

             <<"Try again..."<<endl;

         cout<<"Enter standard time meridiem (a for AM p for PM): ";

         cin>>AorP;

    }

    //call function to calculate the military time

    MilitaryTime(SHour, SMin, AorP, MHour, MMin);

    //fill zeros and display standard time

    cout.width(2);

    cout.fill('0');

    cout<<SHour<<":";

    cout.width(2);

    cout.fill('0');

    cout<<SMin;

    if(AorP=='a' || AorP=='A')

         cout<<" am = ";

    else

         cout<<" pm = ";

    //fill zeros and display military time

    cout.width(2);

    cout.fill('0');

    cout<<MHour;

    cout.width(2);

    cout.fill('0');

    cout<<MMin<<endl;

    system("PAUSE");

    return 0;

}

//function to calculate the military time with reference parameters

void MilitaryTime(int SHour, int SMin, char AorP, int &MHour, int &MMin)

{

    //check the meredium is am or pm

    //and calculate hours

    if(AorP=='a' || AorP=='A')

    {

         if(SHour==12)

             MHour = 0;

         else

             MHour = SHour;

    }

    else

         MHour = SHour+12;

    MMin = SMin;

You might be interested in
all of the following are steps in the problem solving process except a. try, b. reflect, c. debug, d. define
IceJOKER [234]

Answer:

a

Explanation:

5 0
2 years ago
Using the Distortion-Energy failure theory: 8. (5 pts) Calculate the hydrostatic and distortional components of the stress 9. (1
WITCHER [35]

Answer:

Detailed solution is given below:

7 0
3 years ago
What does this middle button on the middle of my Chevrolet equinox steering wheel mean?
almond37 [142]

Answer:

Depending on how new your vehicle is, to me it looks like some sort of turn on button for forward collision safety feature, but i'm not an expert with this particular vehicle. If you want a better answer, I strongly suggest looking at the owner's manual under which should be located in the front dash compartment on the passengers side. Once you have the manual, look in the appendix until you find controls (or something similar) then go to that page and read about your vehicles control buttons. Your answer should be in the manual.

Something that all automobile owners should do right after purchasing a new vehicle, is reading the owners manual. As boring as it may seem, reading the owner's manual will help you get used to your new car quicker and give you instructions on how to take care of your car so that it lasts.

Have a great day, and I wish you safe traveling for now and forever! :)

 

7 0
3 years ago
Read 2 more answers
A ductile hot-rolled steel bar has a minimum yield strength in tension and compression of Syt = 60 kpsi and Syc = 75 kpsi. Using
kow [346]

Answer:

2.135

Explanation:

Lets make use of these variables

Ox 16.5 kpsi, and Oy --14,5 kpsi

To determine the factor of safety for the states of plane stress. We have to first understand the concept of Coulomb-Mohr theory.

Mohr–Coulomb theory is a mathematical model describing the response of brittle materials such as concrete, or rubble piles, to shear stress as well as normal stress.

Please refer to attachment for the step by step solution.

4 0
3 years ago
In the last 5 meters of braking, you lose ___ of your speed.
expeople1 [14]

Answer:

answer is

a)

3/4

Explanation:

In the last 5 meters of braking, you lose 3/4 of your speed.

5 0
2 years ago
Other questions:
  • A 15 cm × 15 cm circuit board dissipating 20 W of power uniformly is cooled by air, which approached the circuit board at 20C w
    11·1 answer
  • Early American rockets used an RC circuit to set the time for the rocket to begin re-entry after launch (true story). Assume the
    5·1 answer
  • In a four bar mechanism, L, is a fixed link; L2 is driver crank; L3 is coupler and L4 is follower crank. L=27 cm, L3 =5 cm and L
    5·1 answer
  • Air enters the compressor of an ideal Brayton refrigeration cycle at 100 kPa, 270 K. The compressor pressure ratio is 3, and the
    13·1 answer
  • Sadadasdasdasdasdadaaasd1
    14·1 answer
  • Print reading for industry unit 9 review questions
    6·2 answers
  • A long bone is subjected to a torsion test. Assume that the inner diameter is 0.375 in. and the outer diameter is 1.25 in., both
    14·1 answer
  • The phase sequence of a 3-phase system for which VAN = 120 /90o V and VBN = 120 /210o V is:_______
    11·1 answer
  • It describes the physical and social elements common to this work. Note that common contexts are listed toward the top, and less
    10·2 answers
  • What are the partial products of 2.3 x 2.6
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!