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
Jade wanted to test the effect of ice on the weathering of rocks. She filled two containers with gypsum and placed a water ballo
Aleks [24]

Answer:

 

The gypsum block with the water balloon has contracted.

Explanation:

7 0
2 years ago
1. Which type of fit implies that a piece will never fit? a. interference fit b. construction fit c. transition fit d. impeding
VladimirAG [237]

Answer:

d

Explanation:

interference fit: the dimensions are larger and high force like heating is required to fit in the object

transition fit: the dimensions are fractionally larger and slight force like hammering is required to fit in the object

impeding fit: the dimensions are larger and the object will not fit at all

construction fit: activities making a commercial space sutiable for tenant occupation.

6 0
3 years ago
Ignition for heavy fuel oil?
ipn [44]

Answer:

What heavy fuel oil?

Heavy Fuel Oil (HFO) is a category of fuel oils of a tar-like consistency. Also known as bunker fuel, or residual fuel oil, HFO is the result or remnant from the distillation and cracking process of petroleum.

Explanation:

7 0
3 years ago
Read 2 more answers
Determine the number of flipflops required to build a binary counter that count from 0 to 2043
Pie

Answer:

10 flip -flops are required to build a binary counter circuit to count to from 0 to 1023 .

Explanation:

3 0
3 years ago
What are two reasons why Hunter edjucation is important?<br><br><br> 30 pts
sasho [114]

Answer:

Hunter Education is Important Because It Helps To: Prevent hunting and shooting accidents. Improve hunter behavior to maintain public acceptance of hunting.

Explanation:

6 0
3 years ago
Other questions:
  • Signal generator‘s internal impedance is purely resistive and has an open-circuit voltage of 3.5 V. When the generator is loaded
    11·1 answer
  • How to build a laser pointer?
    12·1 answer
  • Plot the following trig functions using subplots, choosing an appropriate layout for the number of functions displayed. The subp
    8·1 answer
  • If the resistance reading on a DMM'S meter face is to 22.5 ohms in the range selector switch is set to R X 100 range, what is th
    5·1 answer
  • Is someone an engineer that can help me?plz
    11·1 answer
  • In a typical transmission line, the current I is very small and the voltage V is very large. A unit length of the line has resis
    8·1 answer
  • How can goal setting help with academic performance?
    13·1 answer
  • Water at 70 kPa and 1008C is compressed isentropically in a closed system to 4 MPa. Determine the final temperature of the water
    6·1 answer
  • Think about a good game story that made you feel a mix of positive and negative emotions. What was the story, what emotions did
    13·1 answer
  • 3. What is special about beryllium-copper alloy tools?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!