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
In a paragraph of 125 words, explain at least three ways that engineers explore possible solutions in their
joja [24]

Answer:

Three ways that engineers explore possible solutions in their projects are;

1) Prototyping

2) Simulation

3) Calculations

Explanation:

1) Prototyping is the process of experimental testing of samples of design, or model of a product with the possibility of the inclusion of control of parameters in order to determine the workability of a solution.

2) Simulation is the process of creating an imitation of a situation, operation or process which can be used to determine if a particular solution will be able to work as required in the simulated environment of a problem.

3) Calculations are used to find preliminary results of particular situations, their cause and effects based on scientific laws, theories and hypothesis such that the factor of the problem is equated with the available ideas to find the best possible solution.

3 0
2 years ago
What is future active and future passive and future perfect active
san4es73 [151]
The future perfect tense forms are made by putting ‘will / shall + have’ before the past participle from the verb. these sentences can be changed into the passive if the active verb has an object


i hope this helps :D thanks
5 0
3 years ago
Which of the eight diagnostic steps for locating an engine performance problem is performed first?
Kay [80]

Answer:

D. Perform a thorough visual inspection.

4 0
2 years ago
Gold forms a substitutional solid solution with silver. Compute the number of gold atoms per cubic centimeter for a silver-gold
evablogger [386]

Answer:

Compute the number of gold atoms per cubic centimeter = 9.052 x 10^21 atoms/cm3

Explanation:

The step by step and appropriate substitution is as shown in the attachment.

From number of moles = Concentration x volume

number of moles = number of particles/ Avogadro's number

Volume = mass/density, the appropriate derivation to get the number of moles of atoms

5 0
2 years ago
Using the Rayleigh criterion, calculate the minimum feature size that can be resolved in a system with a 0.18 NA lens when g-lin
Vladimir79 [104]

Answer:

a)

# for a g line, R = 1.211 μm

# for an I-line, R = 1.013 μm

b)

# for a g line, R = 0.726 μm

# for an I-line, R = 0.243 μm

c)

# for a g line, R = 0.605 μm

# for an I-line, R = 0.608 μm

Explanation:

We know that;

Rayleigh Resolution R = 0.5 × λ/NA

for a g line, λ = 436 nm

for an I-line λ = 365 nm

a)

Now when NA = 0.18

# for a g line, λ = 436 nm

R = 0.5 × 436/0.18 =  1.211 μm

# for an I-line λ = 365 nm

R = 0.5 × 365/0.18 =  1.013 μm

b)

when NA = 0.30

# for a g line, λ = 436 nm

R = 0.5 × 436/0.30 =  0.726 μm

# for an I-line λ = 365 nm

R = 0.5 × 365/0.30 =  0.243 μm

c)

when NA = 0.36

# for a g line, λ = 436 nm

R = 0.5 × 436/0.36 =  0.605 μm

# for an I-line λ = 365 nm

R = 0.5 × 365/0.30 =  0.608 μm

6 0
3 years ago
Other questions:
  • The lab technician you recently hired tells you the following: Boss, an undisturbed sample of saturated clayey soil was brought
    6·1 answer
  • Compute the estimated actual endurance limit for SAE 4130 WQT 1300 steel bar with a rectangular cross section of 20.0 mm by 60 m
    11·1 answer
  • A closed, rigid, 0.45 m^3 tank is filled with 12 kg of water. The initial pressure is p1 = 20 bar. The water is cooled until the
    15·1 answer
  • 10. When an adhesion bond is made by melting a filler metal and allowing it to spread into the pores of the
    7·1 answer
  • Which of the following correctly explains why it would be beneficial for an engineer to become a member of the Leadership in Ene
    15·2 answers
  • 3Px=y−y2p2<br><br>first order higher dgree​
    11·1 answer
  • Which system provides an easier way for people to communicate with a computer than a graphical user interface (GUI)?
    15·1 answer
  • What is the difference between a modular home and a manufactured home?
    5·1 answer
  • How does energy transition from one form to another as water moves from behind a dam to downstream of a dam?.
    8·1 answer
  • 3. Which instrument measures the height above the ground?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!