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
Wave flow of an incompressible fluid into a solid surface follows a sinusoidal pattern. Flow is two-dimensional with the x-axis
Artyom0805 [142]

Answer:

sorry , for my point

Explanation:

4 0
3 years ago
The 30-kg gear is subjected to a force of P=(20t)N where t is in seconds. Determine the angular velocity of the gear at t=4s sta
tatyana61 [14]

Answer:

\omega =\frac{24}{1.14375}=20.983\frac{rad}{s}

Explanation:

Previous concepts

Angular momentum. If we consider a particle of mass m, with velocity v, moving under the influence of a force F. The angular  momentum about point O is defined as the “moment” of the particle’s linear momentum, L, about O. And the correct formula is:

H_o =r x mv=rxL

Applying Newton’s second law to the right hand side of the above equation, we have that r ×ma = r ×F =

MO, where MO is the moment of the force F about point O. The equation expressing the rate of change  of angular momentum is this one:

MO = H˙ O

Principle of Angular Impulse and Momentum

The equation MO = H˙ O gives us the instantaneous relation between the moment and the time rate of change of angular  momentum. Imagine now that the force considered acts on a particle between time t1 and time t2. The equation MO = H˙ O can then be integrated in time to obtain this:

\int_{t_1}^{t_2}M_O dt = \int_{t_1}^{t_2}H_O dt=H_0t2 -H_0t1

Solution to the problem

For this case we can use the principle of angular impulse and momentum that states "The mass moment of inertia of a gear about its mass center is I_o =mK^2_o =30kg(0.125m)^2 =0.46875 kgm^2".

If we analyze the staritning point we see that the initial velocity can be founded like this:

v_o =\omega r_{OIC}=\omega (0.15m)

And if we look the figure attached we can use the point A as a reference to calculate the angular impulse and momentum equation, like this:

H_Ai +\sum \int_{t_i}^{t_f} M_A dt =H_Af

0+\sum \int_{0}^{4} 20t (0.15m) dt =0.46875 \omega + 30kg[\omega(0.15m)](0.15m)

And if we integrate the left part and we simplify the right part we have

1.5(4^2)-1.5(0^2) = 0.46875\omega +0.675\omega=1.14375\omega

And if we solve for \omega we got:

\omega =\frac{24}{1.14375}=20.983\frac{rad}{s}

8 0
3 years ago
Most of the work that engineers do with fluids occurs in nature. True False
zlopas [31]
True depending the jobs
3 0
3 years ago
A structural component in the shape of a flat plate 25.0 mm thick is to be fabricated from a metal alloy for which the yield str
balandron [24]

Answer:

The critical length of surface flaw = 6.176 mm

Explanation:

Given data-

Plane strain fracture toughness Kc = 29.6 MPa-m1/2

Yield Strength = 545 MPa

Design stress. =0.3 × yield strength

= 0.3 × 545

= 163.5 MPa

Dimensionless parameter. Y = 1.3

The critical length of surface flaw is given by

= 1/pi.(Plane strain fracture toughness /Dimensionless parameter× Design Stress)^2

Now putting values in above equation we get,

= 1/3.14( 29.6 / 1.3 × 163.5)^2

=6.176 × 10^-3 m

=6.176 mm

5 0
3 years ago
Read 2 more answers
Steam enters a steady-flow adiabatic nozzle with a low inlet velocity (assume ~0 m/s) as a saturated vapor at 6 MPa and expands
Sergio [31]
Yea bro I don’t really know
7 0
3 years ago
Other questions:
  • Steam undergoes an isentropic compression in an insulated piston–cylinder assembly from an initial state where T1 5 1208C, p1 5
    15·1 answer
  • A receptacle, plug, or any other electrical device whose design limits the ability of an electrician to come in contact with any
    14·1 answer
  • Gshyevdnmdcicm gngjc
    13·1 answer
  • Why or why not the following materials will make good candidates for the construction of
    15·1 answer
  • A 860 kΩ resistor has 34 μA of current. What is the supply voltage for this electric circuit?
    13·2 answers
  • Introduction for site visit​
    13·1 answer
  • Please help me with this, picture.
    15·1 answer
  • The gage pressure measured as 2.2 atm, the absolute pressure of gas is 3.2 bar. Please determine the local atmospheric pressure
    14·1 answer
  • The variation of the pressure of a fluid with density at constant temperature is known as the _____.
    5·1 answer
  • Which of the following situations best describes student engaged in active learning
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!