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
kobusy [5.1K]
3 years ago
8

Modify any of the previous labs which would have crashed when non-numeric data was entered by adding exception handling so that

the non-numeric input no longer crashes the program. The program must handle the invalid input gracefully by informing the user of the bad input and re-querying until the user provides valid input. It must re-query for the specific input which was incorrectly entered.
Engineering
1 answer:
Mashutka [201]3 years ago
7 0

Answer:

see explaination

Explanation:

import java.util.InputMismatchException;

import java.util.Scanner;

public class calculate {

static float a=0,b=0;

double cal()

{

if(a==0||b==0)

{

System.out.println("no values found in a or b");

start();

}

double x=(a*a)+(b*b);

double h=Math.sqrt(x);

a=0;

b=0;

return h;

}

float enter()

{

float val=0;

try

{

System.out.println("Enter side");

Scanner sc1 = new Scanner(System.in);

val = sc1.nextFloat();

return val;

}

catch(InputMismatchException e)

{

System.out.println("Enter correct value");

}

return val;

}

void start()

{

calculate c=new calculate();

while(true)

{

System.out.println("Enter Command");

Scanner sc = new Scanner(System.in);

String input = sc.nextLine();

switch(input)

{

case "A":

a=c.enter();

break;

case "B":

b=c.enter();

break;

case "C":

double res=c.cal();

System.out.println("Hypotenuse is : "+res);

break;

case "Q":

System.exit(0);

default:System.out.println("wrong command");

}

}

}

public static void main(String[] args) {

calculate c=new calculate();

c.start();

}

}

You might be interested in
A plate and frame heat exchanger has 15 plates made of stainless steel that are 1 m tall. The plates are 1 mm thick and 0.6 m wi
hodyreva [135]

Answer:

14.506°C

Explanation:

Given data :

flow rate of water been cooled = 0.011 m^3/s

inlet temp = 30°C + 273 = 303 k

cooling medium temperature = 6°C  + 273 = 279 k

flow rate of cooling medium = 0.02 m^3/s

Determine the outlet temperature

we can determine the outlet temperature by applying the relation below

Heat gained by cooling medium = Heat lost by water

= ( Mcp ( To - 6 )  =  Mcp ( 30 - To )

since the properties of water and the cooling medium ( water ) is the same

= 0.02 ( To - 6 ) = 0.011 ( 30 - To )

= 1.82 ( To - 6 ) = 30 - To

hence To ( outlet temperature ) = 14.506°C

6 0
3 years ago
. A two-dimensional fluid motion is represented by a point vortex of strength Γ set at distance c from an infinite straight soli
Lostsunrise [7]

Answer:

The solution and complete explanation for the above question and mentioned conditions is given below in the attached document.i hope my explanation will help you in understanding this particular question.

Explanation:

8 0
3 years ago
Thank you very much this helped a lot
Len [333]

Answer:

Your welcome i guess

Explanation:

7 0
3 years ago
Read 2 more answers
You have been assigned the task of reviewing the relief scenarios for a specific chemical reactor in your plant. You are current
postnew [5]

Answer:

D=0.016m

Explanation:

From the question we are told that:

Discharge Rate F_r=0.5kgls

Pressure P=15Kpa

Temperature T=25=>298K

Ambient pressure is 1 atm.

Generally the equation for Density is mathematically given by

\rho=\frac{PM}{RT}

\rho=\frac{15*10^5*28.0134*10^{-3}}{8.314*298}

\rho=16.958kg/m^2

Generally the equation for Flow rate is mathematically given by

F_r=\mu A\sqrt{Q \rho P(\frac{2}{Q+1})^{\frac{Q+1}{Q-1}}}

Where

Q=Heat coefficient\ ratio\ of\ Nitrogen

Q=1.4

\mu= Discharge\ coefficient

\mu=0.68

Therefore

0.5=0.68 A\sqrt{1.4 16.958 15*10^{5}(\frac{2}{1.4+1})^{\frac{1.4+1}{1.4-1}}}

A=2.129*10^{-4}

Where

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

\frac{\pi}{4}D^2=2.129*10^{-4}

D=0.016m

8 0
3 years ago
What has alternating electric and magnetic fields that travel in the form of a wave?
ad-work [718]

Answer:

a electromagnet

Explanation:

8 0
2 years ago
Other questions:
  • 3. When starting an automatic transmission
    6·1 answer
  • A harmonic oscillator with spring constant, k, and mass, m, loses 3 quanta of energy, leading to the emission of a photon.
    13·1 answer
  • A drainage ditch alongside a highway with a 3% grade has a rectangular cross-section of depth 4 ft and width 8 ft, and is fully
    12·1 answer
  • -0-1"<br> -0<br> -20<br> -15<br> -10<br> 0<br> -5
    9·1 answer
  • A civil engineer is analyzing the compressive strength of concrete. The compressive strength is approximately normal distributed
    7·1 answer
  • Cast iron has about how much carbon content?
    12·1 answer
  • Which of the following best describes the basic purpose of the internet?
    7·2 answers
  • What were some of the challenges to safety resulting from such radical airframe designs as highly swept wings, high wing loading
    15·1 answer
  • The controller determines if a(n) _________ exists by calculating the difference between the SP and the PV.
    6·1 answer
  • An open tank contain oil of specific gravity 0.75 on top of
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!