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
valina [46]
3 years ago
6

Write a program that prompts the user to enter time in 12-hour notation. The program then outputs the time in 24-hour notation.

Your program should contain three exception classes: InvalidHr, InvalidMin, and InvalidSec. If user enters invalid value for hour, then the program should throw and catch an InvalidHr object. Same applies to the invalid value for minutes and seconds.
Engineering
1 answer:
Juliette [100K]3 years ago
4 0

Answer:

THE CODE FOR THE PROGRAM IS GIVEN BELOW:

#include <iostream>

#include "ConvertTimeHeader.h"

using namespace std;

int main()

{

convertTime convert;

int hr, mn, sc = 0;

 

cout << "Please input hours in 12 hr notation: ";

cin >> hr;

cout << "Please input minutes: ";

cin >> mn;

cout << "Please input seconds: ";

cin >> sc;

 

convert.invalidHr(hr);

convert.invalidMin(mn);

convert.invalidSec(sc);

convert.printMilTime();

 

system("Pause");

 

return 0;  

 

}

#include <iostream>

#include "ConvertTimeHeader.h"

using namespace std;

int convertTime::invalidHr (int hour)

{

try{

 if (hour < 13 && hour > 0)

  {hour = hour + 12;

  return hour;}

 else{

 

  cin.clear();

  cin.ignore();

  cout << "Invalid input! Please input hour again in correct 12 hour format: ";

  cin >> hour;

  invalidHr(hour);

  throw 10;

 }

   

}

catch (int c) { cout << "Invalid hour input!";}

}

int convertTime::invalidMin (int min)

{

try{

 if (min < 60 && min > 0)

  {return min;}

 else{

 

  cin.clear();

  cin.ignore();

  cout << "Invalid input! Please input minutes again in correct 12 hour format: ";

  cin >> min;

  invalidMin(min);

  throw 20;

  return 0;

 }

   

}

catch (int e) { cout << "Invalid minute input!" << endl;}

}

int convertTime::invalidSec(int sec)

{

try{

 if (sec < 60 && sec > 0)

  {return sec;}

 else{

 

  cin.clear();

  cin.ignore();

  cout << "Invalid input! Please input seconds again in correct 12 hour format: ";

  cin >> sec;

  invalidSec(sec);

  throw 30;

  return 0;

 }

   

}

catch (int t) { cout << "Invalid second input!" << endl;}

}

void convertTime::printMilTime()

{

cout << "Your time converted: " << hour << ":" << min << ":" << sec;

}

Explanation:

You might be interested in
What is the best way to submit your assignments?
Mrac [35]
A. Email your teacher right away. It would be the safest option.
4 0
3 years ago
Read 2 more answers
What are the maximum weights for single, tandem and 5-axle combinations?
belka [17]
Hauling Vehicles that include a semitrailer manufactured prior to or in the model year of 2024, and registered in Illinois prior to January 1, 2025, having 5 axles with a distance of 42 feet or less between extreme axles, may not exceed the following maximum weights: 20,000 pounds on a single axle; 34,000 pounds
7 0
3 years ago
For some transformation having kinetics that obey the Avrami equation, the parameter n is known to have a value of 2. If, after
kotegsom [21]

This question is incomplete, the complete question is;

For some transformation having kinetics that obey the Avrami equation, the parameter n is known to have a value of 2. If, after 100 s, the reaction is 40% complete, how long (total time in seconds) will it take the transformation to go to 95% completion

y = 1 - exp( -ktⁿ )

Answer: the time required for 95% transformation is 242.17 s

Explanation:

First, we calculate the value of k which is the dependent variable in Avrami equation

y = 1 - exp( -ktⁿ )

exp( -ktⁿ ) = 1 - y

-ktⁿ = In( 1 - y )

k = - In( 1 - y ) / tⁿ

now given that; n = 2, y = 40% = 0.40, and t = 100 s

we substitute

k = - In( 1 - 0.40 ) / 100²

k = - In(0.60) / 10000

k = 0.5108 / 10000

k = 0.00005108 ≈ 5.108 × 10⁻⁵

Now calculate the time required for 95% transformation

tⁿ = - In( 1 - y ) / k

t = [- In( 1 - y ) / k ]^1/n

n = 2, y = 95% = 0.95 and k = 5.108 × 10⁻⁵

we substitute our values

t = [- In( 1 - 0.95 ) / 5.108 × 10⁻⁵ ]^1/2

t = [2.9957 / 5.108 × 10⁻⁵]^1/2

t = [ 58647.22 ]^1/2

t = 242.17 s

Therefore the time required for 95% transformation is 242.17 s

8 0
3 years ago
Who works alongside and assists the engineers?
nika2105 [10]

Answer:

<u>Assistants</u><u> </u><u>works alongside and assists the engineers.</u>

5 0
3 years ago
A 10.2 mm diameter steel circular rod is subjected to a tensile load that reduces its cross- sectional area to 52.7 mm^2. Determ
VMariaS [17]

Answer:

The percentage ductility is 35.5%.

Explanation:

Ductility is the ability of being deform under applied load. Ductility can measure by percentage elongation and percentage reduction in area. Here, percentage reduction in area method is taken to measure the ductility.

Step1

Given:

Diameter of shaft is 10.2 mm.

Final area of the shaft is 52.7 mm².

Calculation:

Step2

Initial area is calculated as follows:

A=\frac{\pi d^{2}}{4}

A=\frac{\pi\times(10.2)^{2}}{4}

A = 81.713 mm².

Step3

Percentage ductility is calculated as follows:

D=\frac{A_{i}-A_{f}}{A_{i}}\times100

D=\frac{81.713-52.7}{81.713}\times100

D = 35.5%.

Thus, the percentage ductility is 35.5%.

5 0
3 years ago
Other questions:
  • To ensure safe footing on penetrable surfaces,use?
    5·1 answer
  • The following laboratory tests are performed on aggregate samples:a. Specific gravity and absorptionb. Soundnessc. Sieve analysi
    13·1 answer
  • An op-amp is connected in an inverting configuration with R1 = 1kW and R2 = 10kW, and a load resistor connected at the output, R
    9·1 answer
  • Refrigerant-134a enters a diffuser steadily as saturated vapor at 600 kPa with a velocity of 160 m/s, and it leaves at 700 kPa a
    10·2 answers
  • What considerations are included in the Preliminary Floodproofing/Retrofitting Preference Matrix?
    7·1 answer
  • Solving Expressions Analytically 1 point Consider the following equation, which describes the speed of sound a in an ideal gas:
    12·1 answer
  • I really need help i will give brainly plz no funny answers
    14·1 answer
  • Please help ASAP!!
    10·2 answers
  • ───────────────────────────────
    7·1 answer
  • Which of these processes uses a die and a press to form parts?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!