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
A Rankine steam power plant is considered. Saturated water vapor enters a turbine at 8 MPa and exits at condenser at 10 kPa. The
Ray Of Light [21]

Answer:

0.31

126.23 kg/s

Explanation:

Given:-

- Fluid: Water

- Turbine: P3 = 8MPa , P4 = 10 KPa , nt = 85%

- Pump: Isentropic

- Net cycle-work output, Wnet = 100 MW

Find:-

- The thermal efficiency of the cycle

- The mass flow rate of steam

Solution:-

- The best way to deal with questions related to power cycles is to determine the process and write down the requisite properties of the fluid at each state.

First process: Isentropic compression by pump

       P1 = P4 = 10 KPa ( condenser and pump inlet is usually equal )

      h1 = h-P1 = 191.81 KJ/kg ( saturated liquid assumption )

       s1 = s-P1 = 0.6492 KJ/kg.K

       v1 = v-P1 = 0.001010 m^3 / kg

       

       P2 = P3 = 8 MPa( Boiler pressure - Turbine inlet )

       s2 = s1 = 0.6492 KJ/kg.K   .... ( compressed liquid )

- To determine the ( h2 ) at state point 2 : Pump exit. We need to determine the wok-done by pump on the water ( Wp ). So from work-done principle we have:

   

                           w_p = v_1*( P_2 - P_1 )\\\\w_p = 0.001010*( 8000 - 10 )\\\\w_p = 8.0699 \frac{KJ}{kg}

- From the following relation we can determine ( h2 ) as follows:

                          h2 = h1 + wp

                          h2 = 191.81 + 8.0699

                          h2 = 199.88 KJ/kg

                           

Second Process: Boiler supplies heat to the fluid and vaporize

- We have already evaluated the inlet fluid properties to the boiler ( pump exit property ).

- To determine the exit property of the fluid when the fluid is vaporized to steam in boiler ( super-heated phase ).

              P3 = 8 MPa

              T3 = ?  ( assume fluid exist in the saturated vapor phase )

              h3 = hg-P3 = 2758.7 KJ/kg

              s3 = sg-P3 = 5.7450 KJ/kg.K

- The amount of heat supplied by the boiler per kg of fluid to the water stream. ( qs ) is determined using the state points 2 and 3 as follows:

                          q_s = h_3 - h_2\\\\q_s = 2758.7 -199.88\\\\q_s = 2558.82 \frac{KJ}{kg}

Third Process: The expansion ( actual case ). Turbine isentropic efficiency ( nt ).

- The saturated vapor steam is expanded by the turbine to the condenser pressure. The turbine inlet pressure conditions are similar to the boiler conditions.

- Under the isentropic conditions the steam exits the turbine at the following conditions:

             P4 = 10 KPa

             s4 = s3 = 5.7450 KJ/kg.K ... ( liquid - vapor mixture phase )

             

- Compute the quality of the mixture at condenser inlet by the following relation:

                           x = \frac{s_4 - s_f}{s_f_g} \\\\x = \frac{5.745- 0.6492}{7.4996} \\\\x = 0.67947

- Determine the isentropic ( h4s ) at this state as follows:

                          h_4_s = h_f + x*h_f_g\\\\h_4_s = 191.81 + 0.67947*2392.1\\\\h_4_s = 1817.170187 \frac{KJ}{kg}        

- Since, we know that the turbine is not 100% isentropic. We will use the working efficiency and determine the actual ( h4 ) at the condenser inlet state:

                         h4 = h_3 - n_t*(h_3 - h_4_s ) \\\\h4 = 2758.7 - 0.85*(2758.7 - 181.170187 ) \\\\h4 = 1958.39965 \frac{KJ}{kg} \\

- We can now compute the work-produced ( wt ) due to the expansion of steam in turbine.

                        w_t = h_3 - h_4\\\\w_t = 2758.7-1958.39965\\\\w_t = 800.30034 \frac{KJ}{kg}

- The net power out-put from the plant is derived from the net work produced by the compression and expansion process in pump and turbine, respectively.

                       W_n_e_t = flow(m) * ( w_t - w_p )\\\\flow ( m ) = \frac{W_n_e_t}{w_t - w_p} \\\\flow ( m ) = \frac{100000}{800.30034-8.0699} \\\\flow ( m ) = 126.23 \frac{kg}{s}

Answer: The mass flow rate of the steam would be 126.23 kg/s

- The thermal efficiency of the cycle ( nth ) is defined as the ratio of net work produced by the cycle ( Wnet ) and the heat supplied by the boiler to the water ( Qs ):

                        n_t_h = \frac{W_n_e_t}{flow(m)*q_s} \\\\n_t_h = \frac{100000}{126.23*2558.82} \\\\n_t_h = 0.31

Answer: The thermal efficiency of the cycle is 0.31

       

   

7 0
3 years ago
Common car loan duration
chubhunter [2.5K]

Answer:

In 2019, the average term length was 69 months for new cars and 65 months for used vehicles. Most car loans are available in 12 month increments, lasting between two and eight years. The most common loan terms are 24, 36, 48, 60, 72, and 84 months, according to Autotrader

Explanation:

4 0
2 years ago
The fracture toughness of a stainless steel is 137 MPa*m12. What is the tensile impact load sustainable before fracture that a r
Charra [1.4K]

Answer:

7.7 kN

Explanation:

The capacity of a material having a crack to withstand fracture is referred to as fracture toughness.

It can be expressed by using the formula:

K = \sigma Y \sqrt{\pi a}

where;

fracture toughness K = 137 MPam^{1/2}

geometry factor Y = 1

applied stress \sigma = ???

crack length a = 2mm = 0.002

∴

137 =\sigma \times 1  \sqrt{ \pi \times 0.002 }

137 =\sigma \times 0.07926

\dfrac{137}{0.07926} =\sigma

\sigma = 1728.489 MPa

Now, the tensile impact obtained is:

\sigma = \dfrac{P}{A}

P = A × σ

P = 1728.289 × 4.5

P = 7777.30 N

P = 7.7 kN

7 0
3 years ago
Do you think for security reasons everything that happens on the internet should be analyzed by the public security services ?
givi [52]

Answer: yes

Explanation: People post bad things that i think should get taken down i was on an app the other day and people were posting bad things

8 0
3 years ago
Explain the working and performance of a centrifugal clutch with a sketch​
FinnZ [79.3K]

Answer:

A centrifugal clutch works, as the name suggests, through centrifugal force.

One of the most common methods is by mounting the clutch onto the parallel or taper crank shaft of the engine.

When the crank shaft rotates the shaft of the clutch rotates at the same speed as the engine

5 0
2 years ago
Read 2 more answers
Other questions:
  • Why is my lawn mower not starting?
    9·1 answer
  • (a) Draw the Moore finite state machine (FSM) of an electronic combination lock with a RESET button, two number buttons (0 and 1
    12·1 answer
  • A rotating cup viscometer has an inner cylinder diameter of 2.00 in., and the gap between cups is 0.2 in. The inner cylinder len
    9·1 answer
  • Create a function (prob3_5) that will take inputs of vectors x and y in feet, scalar N, scalars L and W in feet and scalars T1 a
    6·1 answer
  • WILL BRAINLIEST IF CORRECT!!!!!<br><br> Some one help ASAP.
    8·1 answer
  • A 100-mm-diameter cast Iron shaft is acted upon by a 10 kN.m bending moment, a 8 kN.m torque, and a 150 kN axial force simultane
    9·1 answer
  • Whats is the purpose of the stator winding​
    13·1 answer
  • Which of the following is a possible unit of ultimate tensile strength?
    10·1 answer
  • Ronny wants to calculate the mechanical advantage. He needs to determine the length of the effort arm and the length of the load
    7·1 answer
  • Based on the pattern, what are the next two terms of the sequence? 9,94,916,964,9256,... A. 91024,94096 B. 9260,91028 C. 9260,92
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!