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
Which of the following is not a primary or fundamental dimension? (a)-mass m (b)-length L (c)- timer t (d)-volume V
jolli1 [7]

Answer:

Volume is not the fundamental dimension. So, option d is correct.

Explanation:

Step1

Fundamental dimension is the dimension in which other quantities depend. These are the basic dimensions. Three basic fundaments dimensions are mass, length and time that is represented as MLT respectively.

Step2

Volume is not the fundamental dimension among them as the volume is cube of length dimension. Thus, volume depends upon length.

Thus, Volume is not the fundamental dimension. So, option d is correct.

8 0
3 years ago
What are factor of safety for brittle and ductile material
galben [10]

Explanation:

Step1

Factor of safety is the number that is taken for the safe design of any component. It is the ratio of failure stress to the maximum allowable stress for the material.

Step2

It is an important parameter for design of any component. This factor of safety is taken according to the environment condition, type of material, strength, type of component etc.

Step3

Different material has different failure stress. So, ductile material fails under shear force. Ductile material’s FOS is based on yield stress as failure stress as after yield point ductile material tends to yield. Brittle material’s FOS is based on ultimate stress as failure stress.

The expression for factor of safety for ductile material is given as follows:

FOS=\frac{\sigma_{yp}}{\sigma_{a}}

Here,\sigma_{f} is yield stress and \sigma_{a} is allowable stress.

The expression for factor of safety for brittle material is given as follows:

FOS=\frac{\sigma_{ut}}{\sigma_{a}}

Here,\sigma_{ut} is ultimate stress and \sigma_{a} is allowable stress.

5 0
3 years ago
ASAP correct answer plss When you are driving, if you see this traffic sign it means
vlabodo [156]

Answer:

C

Explanation:

5 0
3 years ago
(40%) A bank wants to store the account number of its customers (an 8-digit number) in encrypted form on magnetic stripe ATM car
9966 [12]

Answer:

Explanation:

Attached is the solution to the question

3 0
3 years ago
Are the wooden pillars shown in the image below, a dead load?
Brrunno [24]

Answer:

no

Explanation:

it's not a dead load because when load is put on the pillars it's not fully straining it's been slowly getting to be heavier in that period of time before it falls

6 0
3 years ago
Other questions:
  • Technician A says that you don’t need to use an exhaust extraction system when working on vehicles equipped with a catalytic con
    9·1 answer
  • What are the causes of kickback on a table-saw?
    13·1 answer
  • A steady state and continuous separator has a total feed rate of 100. kg/h of a 55.0 wt. % benzene mixture. The balance is tolue
    7·1 answer
  • Someone claims that the shear stress at the center of a circular pipe during fully developed laminar flow is zero. Do you agree
    12·1 answer
  • Air at 300 K and 100 kPa steadily flows into a hair dryer having electrical work input of 1500 W. Because of the size of the air
    6·2 answers
  • A car is traveling at 50 ft/s when the driver notices a stop sign 100 ft ahead and steps on the brake. Assuming that the deceler
    6·1 answer
  • Which of these parts of a cell phone is least likely to be found on the phone's circult board?
    5·1 answer
  • Please help! timed test. This about electrical control. Please be serious.
    15·1 answer
  • Find the general solution of the equation<br>a) Tan A = 1/√3​
    11·1 answer
  • What is the difference between absorbed wavelengths and reflected wavelengths?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!