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
How might an operations manager alter operations to meet customer demand? Name at least two ways.
Citrus2011 [14]
One way is manager changes itself and the other one is the same thing i think.
4 0
3 years ago
PLS HELP ME
Oksana_A [137]

Answer:

The Euler buckling load of a 160-cm-long column will be 1.33 times the Euler buckling load of an equivalent 120-cm-long column.

Explanation:

160 - 120 = 40

120 = 100

40 = X

40 x 100 / 120 = X

4000 / 120 = X

33.333 = X

120 = 100

160 = X

160 x 100 /120 = X

16000 / 120 = X

133.333 = X

4 0
3 years ago
Question 40 and the next Question 41
TEA [102]

Answer:

there's no photo? but I'm willing to help

8 0
2 years ago
A tool chest has 950 N weight that acts through the midpoint of the chest. The chest is supported by feet at A and rollers at B.
Mazyrski [523]

Answer:

P > 142.5 N  (→)

the motion sliding

Explanation:

Given

W = 959 N

μs = 0.3

If we apply

∑ Fy = 0 (+↑)

Ay + By = W

If  Ay = By

2*By = W

By = W / 2

By = 950 N / 2

By = 475 N (↑)

Then  we can get F (the force of friction) as follows

F = μs*N = μs*By

F = 0.3*475 N

F = 142.5 N (←)

we can apply

P - F  > 0

P  > 142.5 N (→)

the motion sliding

6 0
3 years ago
Just some random stufff
NeTakaya

Answer:

Nice!

Explanation:

5 0
3 years ago
Other questions:
  • In , the industries with the most complaints to the Better Business Bureau were banks, cable and satellite television companies,
    13·1 answer
  • Is the ASUS ROG Strix B450-F Gaming amd ryzen 5 3600 ready?
    7·2 answers
  • The time delay of a long-distance call can be determined by multiplying a small fixed constant by the number of communication li
    7·1 answer
  • Before accurate distance standards, a cubit was the length of whose forearm?
    5·1 answer
  • A force is a push or pull in? A.a circle B.an arc C.a straight line
    5·1 answer
  • A moving-coil instrument, which gives full-scale deflection with 0.015 A has a copper coil having resistance of 1.5 Ohm at 15°C
    7·1 answer
  • Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00
    13·1 answer
  • What is the heart of a set of construction drawing?
    10·1 answer
  • 3.
    7·1 answer
  • A bridge a mass of 800 kg and is able to support up to 4 560 kg. What is its structural efficiency?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!