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
You are watching the weather forecast and the weatherman says that strong thunderstorms and possible tornadoes are likely to for
WITCHER [35]

Explanation:

bad weather usually form when low pressure pushed high pressure ot the way.

5 0
3 years ago
3 MAOP stands for which of the following?
raketka [301]

Answer:

MAOP Master of Arts in Organizational Psychology (various universities)

MAOP Maximum Allowable Operating Pressure

MAOP Mid-Atlantic Association of Oracle Professionals

MAOP Mid Atlantic Oncology Program

MAOP Maryland Association of Osteopathic Physicians

MAOP Master Air Operations Planner

MAOP Meharry Association of Office Personnel

MAOP Managers' Annual Operating Plan

MAOP Military Assistance Officer Program (US DoD)

Explanation:

3 0
3 years ago
1. A thin-walled cylindrical pressure vessel is capped at the end and is subjected to an internal pressure (p). The inside diame
Vesna [10]
I DONT KNOW OKAY UGHHH
6 0
3 years ago
What is an example of a class 2 lever?
9966 [12]

Answer:

A wheelbarrow, a bottle opener, and an oar are examples of second class levers

6 0
3 years ago
Read 2 more answers
A 4-pole, 3-phase induction motor operates from a supply whose frequency is 60 Hz. calculate: 1- the speed at which the magnetic
DiKsa [7]

Answer:

The answer is below

Explanation:

1) The synchronous speed of an induction motor is the speed of the magnetic field of the stator. It is given by:

n_s=\frac{120f_s}{p}\\ Where\ p\ is \ the \ number\ of\ machine\ pole, f_s\ is\ the\ supply \ frequency\\and\ n_s\ is \ the \ synchronous\ speed(speed \ of\ stator\ magnetic \ field)\\Given: f_s=60\ Hz, p=4. Therefore\\\\n_s=\frac{120*60}{4}=1800\ rpm

2) The speed of the rotor is the motor speed. The slip is given by:

Slip=\frac{n_s-n_m}{n_s}. \\ n_m\ is\ the \ motor\ speed(rotor\ speed)\\Slip = 0.05, n_s= 1800\ rpm\\ \\0.05=\frac{1800-n_m}{1800}\\\\ 1800-n_m=90\\\\n_m=1800-90=1710\ rpm

3) The frequency of the rotor is given as:

f_r=slip*f_s\\f_r=0.04*60=2.4\ Hz

4) At standstill, the speed of the motor is 0, therefore the slip is 1.

The frequency of the rotor is given as:

f_r=slip*f_s\\f_r=1*60=60\ Hz

6 0
3 years ago
Other questions:
  • A rigid tank with a volume of 4 m^3 contains argon at 500 kPa and 30 deg C. It is connected to a piston cylinder (initially empt
    14·1 answer
  • The density of a fluid is given by the empirical equation rho 70:5 exp 8:27 107 P where rho is density (lbm/ft3 ) and P is press
    6·1 answer
  • The technique of smoothing out joint compound on either side of a joint is known as which of the following
    14·1 answer
  • What is the standard deviation of the following data set:
    7·1 answer
  • How long will it take a Honda Civic to travel 118 miles if it is travelling at an average speed of 72 mph?
    6·1 answer
  • Who invented a control unit for an artificial heart?<br> ements<br> ante
    8·1 answer
  • Evaluate, please show work as I don't understand. thanks
    5·1 answer
  • An agricultural manager requires
    12·1 answer
  • Why does my delivery date keep changing on my tesla model 3
    13·1 answer
  • It is acceptable to mix used absorbents.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!