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
The solid cylinders AB and BC are bonded together at B and are attached to fixed supports at A and C. The modulus of rigidity is
romanna [79]

Answer:

a) 0.697*10³ lb.in

b) 6.352 ksi

Explanation:

a)

For cylinder AB:

Let Length of AB = 12 in

c=\frac{1}{2}d=\frac{1}{2} *1.1=0.55in\\ J=\frac{\pi c^4}{2}=\frac{\pi}{2}0.55^4=0.1437\ in^4\\

\phi_B=\frac{T_{AB}L}{GJ}=\frac{T_{AB}*12}{3.3*10^6*0.1437}  =2.53*10^{-5}T_{AB}

For cylinder BC:

Let Length of BC = 18 in

c=\frac{1}{2}d=\frac{1}{2} *2.2=1.1in\\ J=\frac{\pi c^4}{2}=\frac{\pi}{2}1.1^4=2.2998\ in^4\\

\phi_B=\frac{T_{BC}L}{GJ}=\frac{T_{BC}*18}{5.9*10^6*2.2998}  =1.3266*10^{-6}T_{BC}

2.53*10^{-5}T_{AB}=1.3266*10^{-6}T_{BC}\\T_{BC}=19.0717T_{AB}

T_{AB}+T_{BC}-T=0\\T_{AB}+T_{BC}=T\\T_{AB}+T_{BC}=14*10^3\ lb.in\\but\ T_{BC}=19.0717T_{AB}\\T_{AB}+19.0717T_{AB}=14*10^3\\20.0717T_{AB}=14*10^3\\T_{AB}=0.697*10^3\ lb.in\\T_{BC}=13.302*10^3\ lb.in

b) Maximum shear stress in BC

\tau_{BC}=\frac{T_{BC}}{J}c=13.302*10^3*1.1/2.2998=6.352\ ksi

Maximum shear stress in AB

\tau_{AB}=\frac{T_{AB}}{J}c=0.697*10^3*0.55/0.1437=2.667\ ksi

8 0
4 years ago
2. A F-22 Raptor has just climbed through an altitude of 9,874 m at 1,567 kph when a disk
BabaBlast [244]

The pressure difference across the sensor housing will be "95 kPa".

According to the question, the values are:

Altitude,

  • 9874

Speed,

  • 1567 kph

Pressure,

  • 122 kPa

The temperature will be:

→ T = 15.04-[0.00649(9874)]

→     = 15.04-64.082

→     = -49.042^{\circ} C

now,

→ P_o = 101.29[\frac{(-49.042+273.1)}{288.08} ]^{(5.256)}

→      = 27.074

hence,

→ The pressure differential will be:

= 122-27

= 95 \ kPa

Thus the above solution is correct.

Learn more about pressure difference here:

brainly.com/question/15732832

3 0
3 years ago
Select the best answer to the questo
Norma-Jean [14]

Answer:

C

Explanation:

7 0
3 years ago
Read 2 more answers
The purification of hydrogen gas is possible by diffusion through a thin palladium sheet. Calculate the number of kilograms of h
diamong [38]

Answer:

M=0.0411 kg/h or 4.1*10^{-2} kg/h

Explanation:

We have to combine the following formula to find the mass yield:

M=JAt

M=-DAt(ΔC/Δx)

The diffusion coefficient : D=6.0*10^{-8} m/s^{2}

The area : A=0.25 m^{2}

Time : t=3600 s/h

ΔC: (0.64-3.0)kg/m^{3}

Δx: 3.1*10^{-3}m

Now substitute the  values

M=-DAt(ΔC/Δx)

M=-(6.0*10^{-8} m/s^{2})(0.25 m^{2})(3600 s/h)[(0.64-3.0kg/m^{3})(3.1*10^{-3}m)]

M=0.0411 kg/h or 4.1*10^{-2} kg/h

8 0
3 years ago
• Build upon the results of problem 3-85 to determine the minimum factor of safety for fatigue based on infinite life, using the
Rudik [331]

Answer:

minimum factor of safety for fatigue is = 1.5432

Explanation:

given data

AISI 1018 steel cold drawn as table

ultimate strength Sut = 63.800 kpsi

yield strength Syt = 53.700 kpsi

modulus of elasticity E = 29.700 kpsi

we get here

\sigma a = \sqrt{(\sigma a \times kb)^2+3\times (za\times kt)^2}    ...........1

here kb and kt = 1 combined bending and torsion fatigue factor

put here value and we get

\sigma a =  \sqrt{(12 \times 1)^2+3\times (0\times 1)^2}  

\sigma a = 12 kpsi

and

\sigma m = \sqrt{(\sigma m \times kb)^2+3\times (zm\times kt)^2}     ...........2

put here value and we get

\sigma m = \sqrt{(-0.9 \times 1)^2+3\times (10\times 1)^2}  

\sigma m = 17.34 kpsi

now we apply here goodman line equation here that is

\frac{\sigma m}{Sut} +  \frac{\sigma a}{Se} = \frac{1}{FOS}     ...................3

here Se = 0.5 × Sut

Se = 0.5 × 63.800 = 31.9 kspi

put value in equation 3 we get

\frac{17.34}{63.800} +  \frac{12}{31.9} = \frac{1}{FOS}  

solve it we get

FOS = 1.5432

6 0
3 years ago
Other questions:
  • The temperature of a flowing gas is to be measured with a thermocouple junction and wire stretched between two legs of a sting,
    8·1 answer
  • What are the basic types of heat exchangers?
    9·1 answer
  • Which of the following does NOT describe product design.
    11·1 answer
  • What parts does the block contain?
    5·2 answers
  • Consider a two-dimensional incompressible velocity potential phi = ???????? cos theta + ????????theta, where B and L are constan
    8·1 answer
  • Which engineers are requried to have a PE (professional engineer) license?
    13·2 answers
  • For Laminar flow conditions, what size pipe will deliver 90 gpm of medium oil at 40°F (υ = 6.55 * 10^‐5)?
    12·1 answer
  • An Otto cycle with air as the working fluid has a compression ratio of 8.2. Under cold air standard conditions, what is the ther
    14·1 answer
  • Two ball bearings from different manufacturers are being considered for a certain application. Bearing A has a catalog rating of
    10·1 answer
  • Water flow enters a pipe at a velocity of 1m/s. The pipe inlet is 10cm. The pipe outlet is 6cm. 1. Determine the velocity of the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!