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
Visual perception is a mental process that is non selective<br> True<br> False
NARA [144]

The statement "Visual perception is a mental process that is non selective" is false, it is a psychic function that allows the organism to capture, elaborate and interpret selective information that comes from the environment.

<h2>What is visual perception?</h2>

Visual perception is that inner sensation of apparent knowledge, resulting from a specific stimulus or light impression recorded by the eyes.

<h3>Characteristics of visual perception</h3>

  • It incorporates the sensory stimuli received from objects, situations or events and converts them into a meaningful interpretation experience.

  • It is an active process of the brain through which an external reality is created by transforming the light information captured by the eye.

Therefore, we can conclude that visual perception is the interpretation made by the brain of the different organisms of the stimuli received through the senses.

Learn more about visual perception here: brainly.com/question/10259599

3 0
3 years ago
The Fisher effect says that _______ . Group of answer choices the nominal interest rate adjusts one for one with the inflation r
Greeley [361]

Answer:

what wrong subject

Explanation:

7 0
3 years ago
A __________ is a single lane used by drivers to enter and exit a freeway. a) Climbing lane b) Weave lane c) Thru lane d) Offset
Rufina [12.5K]

A Weave lane is a single lane used by drivers to enter and exit a freeway.

<h3>What is this lane about?</h3>

Weave lanes are known to be lanes that acts as an entrance and exits for a lot of cars in highways.

Hence, one can say that A Weave lane is a single lane used by drivers to enter and exit a freeway.

Learn more about Weave lane from

brainly.com/question/10828527

#SPJ1

6 0
2 years ago
Since the engineering design process may take the engineer back to its beginning, the process is considered ________
Valentin [98]

Answer:

Cyclical

Explanation:

I looked at the next question on edgenuity and it said it in the question.

7 0
3 years ago
Consider a thin suspended hotplate that measures 0.25 m × 0.25 m. The isothermal plate has a mass of 3.75 kg, a specific heat of
Orlov [11]

Answer:

Heat losses by convection, Qconv = 90W

Heat losses by radiation, Qrad = 5.814W

Explanation:

Heat transfer is defined as the transfer of heat from the heat surface to the object that needs to be heated. There are three types which are:

1. Radiation

2. Conduction

3. Convection

Convection is defined as the transfer of heat through the actual movement of the molecules.

Qconv = hA(Temp.final - Temp.surr)

Where h = 6.4KW/m2K

A, area of a square = L2

= (0.25)2

= 0.0625m2

Temp.final = 250°C

Temp.surr = 25°C

Q = 64 * 0.0625 * (250 - 25)

= 90W

Radiation is a heat transfer method that does not rely upon the contact between the initial heat source and the object to be heated, it can be called thermal radiation.

Qrad = E*S*(Temp.final4 - Temp.surr4)

Where E = emissivity of the surface

S = boltzmann constant

= 5.6703 x 10-8 W/m2K4

Qrad = 5.6703 x 10-8 * 0.42 * 0.0625 * ((250)4 - (25)4)

= 5.814 W

7 0
4 years ago
Other questions:
  • Given int variables k and total that have already been declared, use a do...while loop to compute the sum of the squares of the
    15·1 answer
  • The reverse water-gas shift (RWGS) reaction is an equimolar reaction between CO2 and H2 to form CO and H2O. Assume CO2 associati
    10·1 answer
  • Carbon resistors often come as a brown cylinder with colored bands. These colored bands can be read to determine the manufacture
    7·1 answer
  • Select the correct answer.<br> Which equation gives you the amount of work performed?
    14·1 answer
  • or a metal pipe used to pump tomato paste, the overall heat- transfer coefficient based on internal area is 2 W/(m2 K). The insi
    14·1 answer
  • A four-cylinder, four-stroke internal combustion engine operates at 2800 RPM. The processes within each cylinder are modeled as
    5·1 answer
  • Water enters a centrifugal pump axially at atmospheric pressure at a rate of 0.12 m3
    10·1 answer
  • Should i show my face?
    8·2 answers
  • How can input from multiple individuals improve design solutions for problems that occur because of a natural disaster, such as
    5·1 answer
  • If a 9V battery produces a current of 3 A through a load, what is the resistance of the load
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!