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
Select the correct answer. Jennifer, a construction manager at a construction firm, has to hire several contractors and subcontr
Ymorist [56]
A. Quality management
7 0
3 years ago
Read 2 more answers
Air enters a diffuser operating at steady state at 540°R, 15 lbf/in.2, with a velocity of 600 ft/s, and exits with a velocity of
yKpoI14uk [10]

Answer: Hello the question is incomplete below is the missing part

Question:  determine the temperature, in °R, at the exit

answer:

T2= 569.62°R

Explanation:

T1 = 540°R

V2 = 600 ft/s

V1 = 60 ft/s

h1 = 129.0613  ( value gotten from Ideal gas property-air table )

<em>first step : calculate the value of h2 using the equation below </em>

assuming no work is done ( potential energy is ignored )

h2 = [ h1 + ( V2^2 - V1^2 ) / 2 ] * 1 / 32.2 * 1 / 778

∴ h2 = 136.17 Btu/Ibm

From Table A-17

we will apply interpolation

attached below is the remaining part of the solution

8 0
3 years ago
A vertical curve is designed for 55 mi h and has an intial grade of +2.5
Dafna1 [17]

Vertical curves are the curves which provide a vehicle to negotiate elevation rate change at a slow rate.

<u>Explanation:</u>

A vertical curve gives a progress between two slanted roadways, permitting a vehicle to arrange the height rate change at a slow rate as opposed to a sharp cut.

In any event four distinct criteria for building up lengths of list vertical bends are perceived somewhat. These are (1) front light sight separation, (2) rider comfort, (3) waste control, and (4) a dependable guideline for outward presentation.

8 0
3 years ago
Your ship has loaded 9,000 barrels of fuel oil at a cargo temperature of 35° C (95° F). API gravity is 44°. The volume correctio
evablogger [386]

Answer:

8 820 barrels

Explanation:

Data:

The number of barrels loaded = 9 000

cargo temperature                    = 35 °C

API                                              = 44 ° C

Barrels when the cargo temperature is 55° F from the determination = 8 820 barrels.

8 0
3 years ago
What Thermal efficiency
siniylev [52]
Of a heat heat engine is the percentage of heat energy that is transformed into work. i’m not sure what your question is tho
5 0
3 years ago
Read 2 more answers
Other questions:
  • . Consider the single-engine light plane described in Prob. 2. If the specific fuel consumption is 0.42 lb of fuel per horsepowe
    9·1 answer
  • A curve with 0.3 m constant radius contains a bead that is moving on it such that its rotational velocity is 3t2 sec-1. If the b
    12·1 answer
  • A fluid flows steadily through a pipe with a uniform cross sectional area. The density of the fluid decreases to half its initia
    6·1 answer
  • A Scalar can only be a positive quantity that has a magnitude but no direction ? a)-True b)-False
    5·1 answer
  • What is the pressure at the bottom of a 25 ft volume of hydraulic fluid with a weight density of 55 lb/ft3 a. 114.6 psi b. 1375p
    7·1 answer
  • What is Pressure measured from absolute zero pressure called?
    14·1 answer
  • Which is the required type of fire extinguisher for standard naval vessels
    9·1 answer
  • 2. What is the original length of the rectangular bar if the deformation is 0.005 in with a force of 1000 lbs and an area of 0.7
    9·1 answer
  • Pedro holds a heavy science book over his head for 10 minutes. Petro is doing work during that time. True or False
    8·1 answer
  • Construction support involves mostly what kind of work?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!