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
Consider laminar, fully developed flow in a channel of constant surface temperature Ts. For a given mass flow rate and channel l
Pachacha [2.7K]

Answer:

Please see attachment.

Explanation:

8 0
3 years ago
The following program includes fictional sets of the top 10 male and female baby names for the current year. Write a program tha
otez555 [7]

Answer:

Define Variables and Use List methods to do the following

Explanation:

#<em>Conjoins two lists together</em>

all_names = male_names.union(female_names)

#<em>Finds the names that appear in both lists, just returns those</em>

neutral_names = male_names.intersection(female_names)

#<em>Returns names that are NOT in both lists</em>

specific_names = male_names.symmetric_difference(female_names)

3 0
3 years ago
Read 2 more answers
Consider a Carnot heat pump cycle executed in a steady-flow system in the saturated mixture region using R-134a flowing at a rat
attashe74 [19]

Answer:

7.15

Explanation:

Firstly, the COP of such heat pump must be measured that is,

              COP_{HP}=\frac{T_H}{T_H-T_L}

Therefore, the temperature relationship, T_H=1.15\;T_L

Then, we should apply the values in the COP.

                           =\frac{1.15\;T_L}{1.15-1}

                           =7.67

The number of heat rejected by the heat pump must then be calculated.

                   Q_H=COP_{HP}\times W_{nst}

                          =7.67\times5=38.35

We must then calculate the refrigerant mass flow rate.

                   m=0.264\;kg/s

                   q_H=\frac{Q_H}{m}

                         =\frac{38.35}{0.264}=145.27

The h_g value is 145.27 and therefore the hot reservoir temperature is 64° C.

The pressure at 64 ° C is thus 1849.36 kPa by interpolation.

And, the lowest reservoir temperature must be calculated.

                   T_L=\frac{T_H}{1.15}

                        =\frac{64+273}{1.15}=293.04

                        =19.89\°C

the lowest reservoir temperature = 258.703  kpa                    

So, the pressure ratio should be = 7.15

8 0
3 years ago
A specific internal combustion engine has a displacement volume VD of 5.6 liters. The processes within each cylinder of the engi
Kisachek [45]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the step by step explanation to the question above.

6 0
3 years ago
technician a says an out-of-round drum can cause a pulsating brake pedal. technician b says an out-of-round drum can cause the b
denis-greek [22]

According to the question of the pulsating brake pedal, both A and B are correct.

What causes brake pulsation?

Brake pulsation is mainly caused by warped rotors/brake discs. Excessive hard braking or quick stops, which can significantly overheat the discs, are the primary causes of deformed rotors. When the discs overheat, the composition of the metal disc material changes, resulting in imperfections in the metal's surface. Hotspots are noticeable irregularities. They appear as discoloured areas of the disc material, which are often bluish or blackish in appearance. The brake pedal is the pedal which you press with your foot to slow or stop a vehicle. When the driver presses the brake pedal, the system automatically delivers the appropriate pressure required to prevent colliding with the vehicle in front.

To learn more about brake pulsation
brainly.com/question/28779956

#SPj4

8 0
1 year ago
Other questions:
  • Two well-known NP-complete problems are 3-SAT and TSP, the traveling salesman problem. The 2-SAT problem is a SAT variant in whi
    7·1 answer
  • A team member who has been a good worker for many years has recently been doing poor work. You suspect that he may be tired of h
    6·1 answer
  • A tank with some water in it begins to drain. The function v ( t ) = 46 − 3.5 t determines the volume of the water in the tank (
    12·1 answer
  • During a long run a very well-trained dog can use up to 1000 ‘cal’/hour (Note: Food calories differ by a factor of one thousand
    14·1 answer
  • Cold water at 20 degrees C and 5000 kg/hr is to be heated by hot water supplied at 80 degrees C and 10,000 kg/hr. You select fro
    14·1 answer
  • help me please help me please help me please help me please help me please help me please help me please help me please help me
    13·2 answers
  • calculate force and moment reactions at bolted base O of overhead traffic signal assembly. each traffic signal has a mass 36kg,
    6·1 answer
  • 4. Long term marijuana use can cause
    12·2 answers
  • Is an example of an electrical device.
    13·2 answers
  • The percentage modulation of AM changes from 50% to 70%. Originally at 50% modulation, carrier power was 70 W. Now, determine th
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!