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
What is the terms for this definition? The unique layout and focus of each type of promotion
saveliy_v [14]

Answer:

Explanation:

The term for this definition is format.

7 0
4 years ago
Whats the best used for Arch bridge
SOVA2 [1]

Answer:

China has also been constructing arch bridges for many years. They built the Zhaozhou Bridge in 605 AD, and it is still around today! Modern arch bridges use materials such as concrete, steel and iron.

Explanation:

6 0
3 years ago
Sharon is designing a house in an area that receives a lot of rainfall all year. Which material should she use to stick the wood
kakasveta [241]

Explanation:

She is passionate about architecture, typography, and black & white film ... Since moving to Texas, I've heard a lot of people say, "If you don't like ... Oc, 3.74, 56, 80 ... Not only does the weather have to be clear to pour the concrete, but it ... system that goes within the slab) is complete, any additional rain will

4 0
3 years ago
A worker's hammer is accidentally dropped from the 20th floor of a building under construction. With what velocity does it strik
Illusion [34]

Answer:

Final Velocity (Vf)= 139.864 ft/s

Time (t)= 4,34 s

Explanation:

This is a free fall problem, to solve it we will apply free  fall concepts:

In a free fall the acceletarion is gravity (g) = 9,81 m/s2, if we convert it to ft/s^2 = g= 32.174 ft/s^2

  • Final velocity is Vf= Vo+ g*t[tex]Vf^{2} = Vo^{2} +2*g*h

where h is height (304 ft in this case).

Vo =0 since the hammer wasn't moving when it stared to fall

Then Vf^2= 0 + 2* 32.174 ft/s^2 *304 ft

          Vf^2= 19,561.8224  ft^2/s^2

          Vf=[sqrt{19561.8224 ft^2/s^2}

          Vf=139.864 ft/s

Time t= (Vf-Vo)/g => (139.864 ft/s-0)/32.174 ft/s^2 = 4.34 sec

Good luck!

8 0
3 years ago
Describe the risks associated with their working environment (such as the tools, materials and equipment that they use, spillage
Llana [10]

The risks which are associated with such working environment and not reporting accidental breakages of tools is pollution and damage to the body system of individuals.

<h3>What is Risk?</h3>

This is defined as the possibility of something causing a bad event to occur and is common in workplace when tools are left carelessly which can cause injuries etc.

In the case of a working environment with oil spills, it can lead to slipping of the individuals present in the area and not reporting accidental breakages of tools or equipment could also lead to pollution and different forms of accident which thereby making it the most appropriate choice in this context.

Read more about Risk here brainly.com/question/1224221

#SPJ1

3 0
2 years ago
Other questions:
  • A westbound section of freeway currently has three 12-ft wide lanes, a 6-ft right shoulder, and no ramps within 3 miles upstream
    6·1 answer
  • You are given the following information about a drybatch paving operation. You are going to use one mixer that has a service rat
    10·1 answer
  • A particle is moving along a straight line with an initial velocity of 6 m/s when it is subjected to a deceleration of a- (-1.5v
    8·1 answer
  • Nearly__________ of all serious occupational injuries and illnesses stem from overexertion of repetitive motion.a. 1/2b. 1/4c. A
    10·1 answer
  • If Fred has already measured 14 inches of a table measuring 30 inches. How many inches does he need to measure more?
    15·1 answer
  • Charles, Clarissa, and Francine all work in Manufacturing. The table shows the breakdown of one day for each employee.
    5·2 answers
  • Clutches And Torque Converters both provide all of these EXCEPT:
    14·1 answer
  • Introduce yourself to the class and
    12·1 answer
  • Find the volume of water displaced and position of center of buoyancy for a wooden block of width 2.5m and of depth 1.5m. When i
    14·1 answer
  • All heavy sanding and grinding must be done outside because of grinding
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!