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
Water vapor at 10 MPa, 600°C enters a turbine operating at steady state with a volumetric flow rate of 0.36 m3/s and exits at 0.
elena-s [515]

Answer:

Hook's law holds good up to. A elastic limit. B. plastic limit. C.yield point. D.Breaking point

8 0
3 years ago
When we say that communication is
Harlamova29_29 [7]

Answer:

Communication is simply the act of transferring information from one place, person or group to another. Every communication involves (at least) one sender, a message and a recipient.

Explanation:

3 0
3 years ago
At a point on the free surface of a stressed body, the normal stresses are 20 ksi (T) on a vertical plane and 30 ksi (C) on a ho
victus00 [196]

Answer:

The principal stresses are σp1 = 27 ksi, σp2 = -37 ksi and the shear stress is zero

Explanation:

The expression for the maximum shear stress is given:

\tau _{M} =\sqrt{(\frac{\sigma _{x}^{2}-\sigma _{y}^{2}  }{2})^{2}+\tau _{xy}^{2}    }

Where

σx = stress in vertical plane = 20 ksi

σy = stress in horizontal plane = -30 ksi

τM = 32 ksi

Replacing:

32=\sqrt{(\frac{20-(-30)}{2} )^{2} +\tau _{xy}^{2}  }

Solving for τxy:

τxy = ±19.98 ksi

The principal stress is:

\sigma _{x}+\sigma _{y} =\sigma _{p1}+\sigma _{p2}

Where

σp1 = 20 ksi

σp2 = -30 ksi

\sigma _{p1}  +\sigma _{p2}=-10 ksi (equation 1)

\tau _{M} =\frac{\sigma _{p1}-\sigma _{p2}}{2} \\\sigma _{p1}-\sigma _{p2}=2\tau _{M}\\\sigma _{p1}-\sigma _{p2}=32*2=64ksi equation 2

Solving both equations:

σp1 = 27 ksi

σp2 = -37 ksi

The shear stress on the vertical plane is zero

4 0
3 years ago
DRIVERS ED
forsale [732]

Answer:

b

Explanation:

only if there signal is turned on

8 0
3 years ago
Read 2 more answers
Seawater containing 3.50 wt% salt passes through a series of 11 evaporators. Roughly equal quantities of water are vaporized in
statuscvo [17]

Answer: the mass flow rate of concentrated brine out of the process is 46,666.669 kg/hr

Explanation:

F, W and B are the fresh feed, brine and total water obtained

w = 2 x 10^4 L/h

we know that

F = W + B

we substitute

F = 2 x 10^4 + B

F = 20000 + B .................EQUA 1

solute

0.035F = 0.05B

B = 0.035F/0.05

B = 0.7F

now we substitute value of B in equation 1

F = 20000 + 0.7F

0.3F = 20000

F = 20000/0.3

F = 66666.67 kg/hr

B = 0.7F

B = 0.7 * F

B = 0.7 * 66666.67

B = 46,666.669 kg/hr

the mass flow rate of concentrated brine out of the process is 46,666.669 kg/hr

8 0
3 years ago
Other questions:
  • What is a thermal reservoir?
    15·1 answer
  • While there are many ways to solve this problem, one strategy is to calculate the volume of any metal's unit cell given its theo
    14·1 answer
  • How can the direction of rotation of a split-phase motor be changed? *
    15·2 answers
  • You are designing a geartrain with three spur gears: one input gear, one idler gear,and one output gear. The diametral pitch for
    13·1 answer
  • Which of these parts of a cell phone is least likely to be found on the phone's circult board?
    5·1 answer
  • Please help me with this. Picture
    10·1 answer
  • a motor has torque of 200 nm if i motors attached to an arm with a length of 25 cm and a string is too attached to the end appro
    13·1 answer
  • 3. What type of tool do you use to make angles?
    15·1 answer
  • An open tank contain oil of specific gravity 0.75 on top of
    8·1 answer
  • What is the name of this piece?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!