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
Single point cutting tool removes material from a rotating work piece to generate a cylinder is called • Facing Tuming • Both 1
madam [21]

Answer:Turning

Explanation: Turning is the process in which the work piece is subjected to machining so that excess part is removed with the help of rotation by turning machine or lathe machine.The cutter tool is used for cutting the excess of the work piece and it  is mostly single-pointed so that give accurate removal of the excess of work piece.At times , according to the requirement multi-pointed tool is also used Therefore, the correct option is turning.

6 0
3 years ago
A machine used to shred cardboard boxes for composting has a first cost of $10,000, an AOC of $7000 per year, a 3-year life, and
borishaifa [10]
Annual Payment where F is accumulated sum of amount, n is number of years and i is annual rate of interest. The standard notation equation is in the image since i can’t type it-
6 0
3 years ago
How can we calculate the speed of the output gear in a simple gear train? Explain with the help of an example.
Snowcat [4.5K]

Answer:

N_3=\dfrac{T_1}{T_3}N_1

Explanation:

In the diagram there three gears in which gear 1 is input gear ,gear 2 is idle gear and gear 3 is out put gear.

Lets take

Speed\ of\ gear 1=N_1

Number\ of\ teeth\ of\ gear 1=T_1

Speed\ of\ gear 3=N_3

Number\ of\ teeth\ of\ gear 3=T_3

All external matting gears will rotates in opposite direction with respect to each other.

So the speed of gear third can be given as follows

\dfrac{T_1}{T_3}=\dfrac{N_3}{N_1}

N_3=\dfrac{T_1}{T_3}N_1

3 0
3 years ago
A 0.19-m3 rigid tank equipped with a pressure regulator contains steam at 2 MPa and 300°C. The steam in the tank is now heated.
AVprozaik [17]

Answer:

576.21kJ

Explanation:

#We know that:

The balance mass m_{in}+m_{out}=\bigtriangleup m_{system}

so, m_e=m_1-m_2

Energy \ Balance\\E_{in}-E_{out}=\bigtriangleup E_{system}\\\\\therefore Q_i_n+m_eh_e=m_2u_2-m_1u_1

#Also, given the properties of water as;

(P_1=2Mpa,T_1=300\textdegree C)->v_1=0.12551m^3/kg,u_1=2773.2kJ/kg->h_1=3024.2kJ/kg\\\\(P_2=2Mpa,T_1=500\textdegree C)->v_2=0.17568m^3/kg,u_1=3116.9kJ/kg->h_1=3468.3kJ/kg

#We assume constant properties for the steam at average temperatures:h_e=\approx(h_1+h_2)/2

#Replace known values in the equation above;h_e=(3024.2+3468.3)/2=3246.25kJ/kg\\\\m_1=V_1/v_1=0.19m^3/(0.12551m^3/kg)=1.5138kg\\\\m_2=V_2/v_2=0.19m^3/(0.17568m^3/kg)=1.0815kg

#Using the mass and energy balance relations;

m_e=m_1-m_2\\\\m_e=1.5138-1.0815\\\\m_e=0.4323kg

#We have Q_i_n+m_eh_e=m_2u_2-m_1u_1: we replace the known values in the equation as;

Q_i_n+m_eh_e=m_2u_2-m_1u_1\\\\Q_i_n=0.4323kg\times3246.2kJ/kg+1.0815kg\times3116.9-1.5138kg\times2773.2kJ/kg\\\\Q_i_n=573.21kJ

#Hence,the amount of heat transferred when the steam temperature reaches 500°C is 576.21kJ

5 0
3 years ago
g A steel water pipe has an inner diameter of 12 in. and a wall thickness of 0.25 in. Determine the longitudinal and hoop stress
zvonat [6]

Answer:

a) \mathbf{\sigma _ 1 = 4800 psi}

     \mathbf{ \sigma _2 = 0}

b)\mathbf{\sigma _ 1 = 6000 psi}

  \mathbf{ \sigma _2 = 3000 psi}

Explanation:

Given that:

diameter d = 12 in

thickness t = 0.25 in

the radius = d/2 = 12 / 2 = 6 in

r/t = 6/0.25 = 24

24 > 10

Using the  thin wall cylinder formula;

The valve A is opened and the flowing water has a pressure P of 200 psi.

So;

\sigma_{hoop} = \sigma _ 1 = \frac{Pd}{2t}

\sigma_{long} = \sigma _2 = 0

\sigma _ 1 = \frac{Pd}{2t} \\ \\ \sigma _ 1 = \frac{200(12)}{2(0.25)}

\mathbf{\sigma _ 1 = 4800 psi}

b)The valve A is closed and the water pressure P is 250 psi.

where P = 250 psi

\sigma_{hoop} = \sigma _ 1 = \frac{Pd}{2t}

\sigma_{long} = \sigma _2 = \frac{Pd}{4t}

\sigma _ 1 = \frac{Pd}{2t} \\ \\ \sigma _ 1 = \frac{250*(12)}{2(0.25)}

\mathbf{\sigma _ 1 = 6000 psi}

\sigma _2 = \frac{Pd}{4t} \\ \\  \sigma _2 = \frac{250(12)}{4(0.25)}

\mathbf{ \sigma _2 = 3000 psi}

The free flow body diagram showing the state of stress on a volume element located on the wall at point B is attached in the diagram below

8 0
4 years ago
Other questions:
  • g In the above water treatment facility, chemical concentration (mg/gal) within the tank can be considered uniform. The initial
    8·1 answer
  • What is the name of the model/shape below?
    5·2 answers
  • One type of illumination system consists of rows of strip fluorescents and a ceiling that will transmit light. For this system t
    15·1 answer
  • Sublimation is to change from
    7·2 answers
  • java Write a program that simulates tossing a coin. Prompt the user for how many times to toss the coin. Code a method with no p
    10·2 answers
  • At the grocery store you place a pumpkin with a mass of 12.5 lb on the produce spring scale. The spring in the scale operates su
    5·1 answer
  • What determines the depth of the foundation excavation
    9·2 answers
  • What is your employer required to have on fixed ladders that extend more than 24 feet in the workplace?
    15·2 answers
  • Suppose that tank holds 1% liquid water by volume and 99% vapor water by volume at a temperature of 185oC. What is the quality?
    10·1 answer
  • if stall speed in ktas for an aircraft us 100 ktas at sea level, what is the stall speed in ktas of the aircraft at 5000 ft dens
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!