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
1. In a series circuit the sum of all voltage drops produced by the loads in the circuit
GarryVolchara [31]

Answer:

ik the answer but I'm busy rn

5 0
2 years ago
a sprue is 12 in long and has a diameter of 5 in at the top. The molten metal level in the pouring basing is taken to be 3 in fr
vampirchik [111]

Answer:

See explaination

Explanation:

We can describe Aspiration Effect as a phenomenon of providing an allowance for the release of air from the mold cavity during the metal pouring.

See the attached file for detailed solution of the given problem.

8 0
3 years ago
Read 2 more answers
2. Write a Java program that generates a new string by concatenating the reversed substrings of even indexes and odd indexes sep
Nana76 [90]

Answer:

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        String testString = "abscacd";
  4.        String evenStr = "";
  5.        String oddStr = "";
  6.        for(int i=testString.length() - 1; i >= 0; i--){
  7.            if(i % 2 == 0){
  8.                evenStr += testString.charAt(i);
  9.            }
  10.            else{
  11.                oddStr += testString.charAt(i);
  12.            }
  13.        }
  14.        System.out.println(evenStr + oddStr);
  15.    }
  16. }

Explanation:

Firstly, let declare a variable testString to hold an input string "abscacd" (Line 1).

Next create another two String variable, evenStr and oddStr and initialize them with empty string (Line 5-6). These two variables will be used to hold the string at even index and odd index, respectively.

Next, we create a for loop that traverse the characters of the input string from the back by setting initial position index i to  testString.length() - 1  (Line 8). Within the for-loop, create if and else block to check if the current index, i is divisible by 2, (i % 2 == 0), use the current i to get the character of the testString and join it with evenStr. Otherwise, join it with oddStr (Line 10 -14).

At last, we print the concatenated evenStr and oddStr (Line 18).  

4 0
3 years ago
Discuss three objectives of Tariff and elaborate on three characteristics of it
Margaret [11]

Answer:

Three objectives of a tariff are

1) To control trade between countries

2) To protect domestic industries

3) To provide a source of income

Three characteristics of a tariff are;

1) Adequate return

2) Attractive

3) Fairness

Explanation:

A tariff is an import or export tax placed on goods traded between countries, it serves to control the foreign trade between the two countries and to protect or develop local industry

A Tariff is an important source of income to countries

Three characteristics of a tariff are;

1) Adequate return

Proper return from the consumer should be factored in a tariff to account for the alternatives or normal expense pattern

2) Attractive

The tariff should be attractive to encourage consumption of electricity or complimentary goods

3) Fairness

Based on the consumption of related resources brought about by large scale utilization, large consumer tariff should be lower than those that consume less complementary resources.

5 0
3 years ago
The nuclear reactions resulting from thermal neutron absorption in boron and cadmium are 10B5 + 1 n0 ï  7Li3 + 4He2 113Cd48 + 1
kirill115 [55]

Solution :

The nuclear reaction for boron is given as :

$^{10}\textrm{B}_5 + ^{1}\textrm{n}_0 \rightarrow ^{7}\textrm{Li}_3 + ^{4}\textrm{He}_2$

And the reaction for Cadmium is :

$^{113}\textrm{Cd}_48 + ^{1}\textrm{n}_0 \rightarrow ^{114}\textrm{Cd}_48 + \gamma [5 \ \textrm{MeV}]$

We know that it is easier that to shield or stop an alpha particle (i.e. He nucli) as they can be stopped or obstructed by only a few centimetres of the material. However, the gamma rays ( γ ) can penetrate through the material to a greater distance. Therefore, we can choose the first one.

6 0
3 years ago
Other questions:
  • List irreversibilities
    11·1 answer
  • Given that the debouncing circuit is somewhat expensive in terms of hardware (2 NAND gates, 2 resistors, and a double-pole, sing
    9·1 answer
  • You are considering purchasing a compact washing machine, and you have the following information: The Energy Guide claims an est
    8·1 answer
  • (40%) A bank wants to store the account number of its customers (an 8-digit number) in encrypted form on magnetic stripe ATM car
    7·1 answer
  • The use of zeroes after a decimal point are an indicator of accuracy. a)True b)- False
    7·1 answer
  • You must yield the right-of-way to all of the following EXCEPT:
    8·1 answer
  • What additional information would make the following problem statement stronger? Select all that apply.
    8·1 answer
  • Consider a circuit element, with terminals a and b, that has vab= -12V and iab= 3A. Over a period of 2 seconds, how much charge
    8·1 answer
  • ANSWER ASAP<br> What is the point system?<br> this is for driving
    8·1 answer
  • A system samples a sinusoid of frequency 230 Hz at a rate of 175 Hz and writes the sampled signal to its output without further
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!