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
Why does the ring on saturn spin
spayn [35]

Answer: THERE IS NO GRAVITY IN SPACE SO ROCKS SPIN

Explanation:

8 0
2 years ago
Read 2 more answers
The Energy Losses Associated with Valves and Fittings: a)- are generally associated with a K factor b)- are generally associated
madam [21]

Answer:

a)Are generally associated with factor.

Explanation:

We know that losses are two types

1.Major loss  :Due to friction of pipe surface

2.Minor loss  :Due to change in the direction of flow

As we know that when any hindrance is produced during the flow of fluid then it leads to generate the energy losses.If flow is along uniform diameter pipe then there will not be any loss but if any valve and fitting placed is the path of fluid flow due to this direction of fluid flow changes and  it produce losses in the energy.

Lot' of experimental data tell us that loss in the energy due to valve and fitting are generally associated with K factor.These losses are given as

Losses=K\dfrac{V^2}{2g}

8 0
3 years ago
Write short notes on: (any four) a) Suspended ground floor b) Soil exploration c) Baulking of sand d) Bearing capacity of soil e
vredina [299]

Answer:

a) A suspended floor is a ground floor with a void underneath the structure. The floor can be formed in various ways, using timber joists, precast concrete panels, block and beam system or cast in-situ with reinforced concrete. However, the floor structure is supported by external and internal walls.

b) Soil exploration consists of determining the profile of the natural soil deposits at the site, taking the soil samples and determining the engineering properties of soils using laboratory tests as well as in-situ testing methods

c) Bulking in sand Occurs When dry sand interacts with the atmospheric moisture. Presence of moisture content forms a thin layer around sand particles. This layer generates the force which makes particles to move aside to each other. This results in the increase of the volume of sand.

d) In a nutshell, bearing capacity is the capacity of soil to support the loads that are applied to the ground above. It depends primarily on the type of soil, its shear strength and its density. It also depends on the depth of embedment of the load – the deeper it is founded, the greater the bearing capacity.

Explanation:

<h2>please follow me</h2>
6 0
3 years ago
A cylinder with a 6.0 in. diameter and 12.0 in. length is put under a compres-sive load of 150 kips. The modulus of elasticity f
jeka94

Answer:

Final Length = 11.992 in

Final Diameter = 6.001 in

Explanation:

First we calculate the cross-sectional area:

Area = A = πr² = π(3 in)² = 28.3 in²

Now, we calculate the stress:

Stress = Compressive Load/Area

Stress = - 150 kips/28.3 in²

Stress = -5.3 ksi

Now,

Modulus of Elasticity = Stress/Longitudinal Strain

8000 ksi = -5.3 ksi/Longitudinal Strain

Longitudinal Strain = -6.63 x 10⁻⁴

but,

Longitudinal Strain = (Final Length - Initial Length)/Initial Length

-6.63 x 10⁻⁴ = (Final Length - 12 in)/12 in

Final Length = (-6.63 x 10⁻⁴)(12 in) + 12 in

<u>Final Length = 11.992 in</u>

we know that:

Poisson's Ratio = - Lateral Strain/Longitudinal Strain

0.35 = - Lateral Strain/(- 6.63 x 10⁻⁴)

Lateral Strain = (0.35)(6.63 x 10⁻⁴)

Lateral Strain = 2.32 x 10⁻⁴

but,

Lateral Strain = (Final Diameter - Initial Diameter)/Initial Diameter

2.32 x 10⁻⁴ = (Final Diameter - 6 in)/6 in

Final Diameter = (2.32 x 10⁻⁴)(6 in) + 6 in

<u>Final Diameter = 6.001 in</u>

8 0
3 years ago
Need some help with these plz
pashok25 [27]

100: D, third law of motion

101: D, second law of motion

5 0
3 years ago
Other questions:
  • Name two types of Transformers.
    6·1 answer
  • What is the pressure at the bottom of a 25 ft volume of hydraulic fluid with a weight density of 55 lb/ft3 a. 114.6 psi b. 1375p
    7·1 answer
  • What's a disadvantage of highest MERV-rated filters?
    10·2 answers
  • A 14 inch diameter pipe is decreased in diameter by 2 inches through a contraction. The pressure entering the contraction is 28
    10·1 answer
  • A proposed piping and pumping system has 20-psig static pressure, and the piping discharges to atmosphere 160 ft above the pump.
    8·1 answer
  • A Pelton wheel is supplied with water from a lake at an elevation H above the turbine. The penstock that supplies the water to t
    6·1 answer
  • Tech A says you can find the typical angle of a V-block engine by dividing the number of cylinders by 720
    11·1 answer
  • HELP ASSAPPP
    15·1 answer
  • ​please how to drawing mechanical drawing after connecting the all parts thanks
    6·1 answer
  • The toggle (t) flip-flop has one input, clk, and one output, q. on each rising edge of clk, q toggles to the complement of its p
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!