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
In order to impress your neighbors and improve your vision in traffic jams, you decide to mount a cylindrical periscope 2.0 m hi
kondaur [170]
Follow @richard.gbe on Instagram for the answer
5 0
4 years ago
The correct area in sq. Inches and sq. Feet is: Select one: a. 966.76 sq. Inches and 8.056 sq. Feet b. 96.676 sq. Inches and 8.0
kogti [31]

Answer:

c. 96.676 sq. Inches and 0.671 sq. Feet

Explanation:

From the list of the given option, we are told to chose the correct area in sq. inches that correspond to sq. Feet.

If we recall from the knowledge of our conversion  table that,

1 sq feet = 144 sq inches

Then, let's confirm if the option were true.

a.  966.76 sq. Inches and 8.056 sq. Feet

Assuming

if 1 sq feet = 8.056

in sq inches, we have ( 8.056 × 144 ) sq inches

= 1160.064 sq. inches

So, 1160.064 sq. inches is equal to 8.056 sq. Feet. Then option 1 is wrong

b. 96.676 sq. Inches and 8.056 sq. Feet

if 1 sq feet = 8.056

in sq inches, we have ( 8.056 × 144 ) sq inches

= 1160.064 sq. inches

So, 1160.064 sq. inches is equal to 8.056 sq. Feet. Then option 2 is wrong/

c. 96.676 sq. Inches and 0.671 sq. Feet

if 1 sq feet = 0.671

in sq inches, we have ( 0.671 × 144 ) sq inches

=  96.624 sq. Inches which is closely equal to 96.676 sq. Inches

Therefore, this is the correct answer as it proves that 96.676 sq. Inches = 0.671 sq. Feet

8 0
3 years ago
Please help me do this with my exam tomorrow.
blagie [28]

Answer:

ddddddddddddddddddddddddddddd

Explanation:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

6 0
2 years ago
When your hands are on home row, they are resting on the____.
MArishka [77]

Answer:

to which four fingers of each hand return as a base, on a QWERTY keyboard being A, S, D, and F for the left hand and J, K, L, and the semicolon for the right

Explanation:

4 0
3 years ago
Read 2 more answers
A certain servomechanism system has dynamics dominated by a pair of complex poles and no finite nan specifications on the rise t
AveGali [126]

Answer:

The solution is given in the attachments

3 0
3 years ago
Other questions:
  • When the outside temperature is 5.2 ⁰C, a steel beam of cross-sectional area 52 cm2 is installed in a building with the ends of
    8·1 answer
  • I am trying to create a line of code to calculate distance between two points. (distance=[tex]\sqrt{ (x2-x1)^2+(y2-y1)^2}) My li
    5·1 answer
  • Transcription machinery assembles at _______________.
    6·1 answer
  • The impeller shaft of a fluid agitator transmits 28 kW at 440 rpm. If the allowable shear stress in the impeller shaft must be l
    6·1 answer
  • Consider a 0.15-mm-diameter air bubble in a liquid. Determine the pressure difference between the inside and outside of the air
    10·1 answer
  • Part A What is the correct expression of the internal torque in segment AB? A shaft is fixed at A. A clockwise distributed torqu
    6·1 answer
  • If they opened up the International Space Station to tourism, would you go? Why? answer in 2 sentences
    13·2 answers
  • Report of invertor to convert 12 volt to 220 volt.
    6·1 answer
  • A) If a given directional antenna can receive 15 times the power of an isotropic antenna, what is
    11·1 answer
  • yolanda went to get her car fixed. it cost $50 for the part and $200 for each hour the mechanic worked on it. if x represents th
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!