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
white Sands national monument is a large area made of white sand dunes. what is likely to be true of this area?​
Margarita [4]

Answer:

yes

Explanation:

because i said so

7 0
3 years ago
(TCO 1) Name one disadvantage of fixed-configuration switches over modular switches. a. Ease of management b. Port security b. F
frutty [35]

Answer:

The answer is A.

Explanation:

Two main types of network switches, modular and fixed configuration switches, are used for connecting the devices with one another provided they are on the same network.

As the name suggests, modular switches can be configured according to your needs and specific situations where you need a different setup.

The one advantage fixed-configuration switches have over the modular switches is that they are easier to operate. You can't change anything for a different application but they are simpler to setup and use, you can just plug them in and start using. They are usually for the more casual end-user and home networks etc.

I hope this answer helps.

5 0
3 years ago
This manometer is used to measure the difference in water level between the two tanks.
SpyIntel [72]

Answer:

a) True

Explanation:

hope it helps u

3 0
2 years ago
Air modeled as an ideal gas enters a combustion chamber at 20 lbf/in.2
motikmotik

Answer:

The answer is "112.97 \ \frac{ft}{s}"

Explanation:

Air flowing into thep_1 = 20 \ \frac{lbf}{in^2}

Flow rate of the mass m  = 230.556 \frac{lbm}{s}

inlet temperature T_1 = 700^{\circ} F

PipelineA= 5 \times 4 \ ft

Its air is modelled as an ideal gas Apply the ideum gas rule to the air to calcule the basic volume v:

\to \bar{R} = 1545 \ ft \frac{lbf}{lbmol ^{\circ} R}\\\\ \to M= 28.97 \frac{lb}{\bmol}\\\\ \to pv=RT \\\\\to v= \frac{\frac{\bar{R}}{M}T}{p}

      = \frac{\frac{1545}{28.97}(70^{\circ}F+459.67)}{20} \times \frac{1}{144}\\\\=9.8 \frac{ft3}{lb}

V= \frac{mv}{A}

   = \frac{230.556 \frac{lbm}{s} \times 9.8 \frac{ft^3}{lb}}{5 \times 4 \ ft^2}\\\\= 112.97 \frac{ft}{s}

8 0
3 years ago
You work for a printing company, and you realize that your colleague sent incorrect price quotes to a client. You begin to write
xxTIMURxx [149]

Answer:

The sentence excerpted from the e-mail uses passive voice.  

Given the  purpose of your message, this voice is appropriate.

Explanation:

Because the objective is to remedy the situation a passive voice is great because it emphasizes the action and the object instead of the subject.

We want to emphasize the document and the incorrect information, not our colleague.

4 0
3 years ago
Other questions:
  • The popularity of orange juice, especially as a breakfast drink, makes it an important factor in the economy of orange-growing r
    14·1 answer
  • Which type of design does not need special care for the placement of dimensions?
    5·1 answer
  • Which happens when a wave passes through an opening
    12·2 answers
  • Yall pls help me out
    7·1 answer
  • I really need help i will give brainly plz no funny answers
    14·1 answer
  • 8. Find the volume of the figure shown below: * V=L x W x H 7 cm 2 cm 2 cm​
    9·1 answer
  • The two major forces opposing the motion of a vehicle moving on a level road are the rolling resistance of the tires, Fr, and th
    7·1 answer
  • Work to be performed can come from the work package level of the work breakdown structure as well as other sources. Which of the
    11·1 answer
  • Accidents occur as a result of ____ and ____.
    7·1 answer
  • Nonconductive safety shoes can be safely worn in a potentially explosive environment.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!