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
An aluminum bar 125 mm long with a square cross section 16 mm on an edge is pulled in tension with a load of 66,700 N and experi
AfilCa [17]

Answer: the modulus of elasticity of the aluminum is 75740.37 MPa

Explanation:

Given that;

Length of Aluminum bar L = 125 mm

square cross section s = 16 mm

so area of cross section of the aluminum bar is;

A = s² = 16² = 256 mm²

Tensile load acting the bar p = 66,700 N

elongation produced Δ = 0.43

so

Δ = PL / AE

we substitute

0.43 = (66,700 × 125) / (256 × E)

0.43(256 × E) = (66,700 × 125)

110.08E = 8337500

E = 8337500 / 110.08

E = 75740.37 MPa

Therefore, the modulus of elasticity of the aluminum is 75740.37 MPa

4 0
3 years ago
Consider laminar, fully developed flow in a channel of constant surface temperature Ts. For a given mass flow rate and channel l
Lisa [10]

Answer:

Please see attachment.

Explanation:

6 0
3 years ago
A 2-cm-diameter vertical water jet is injected upward by a nozzle at a speed of 15 m/s. Determine the maximum weight of a flat p
Ede4ka [16]

Answer:58.28 N

Explanation:

Given data

dia. of nozzle \left ( d\right )=2 cm

initial velocity\left ( u\right )=15 m/s

height\left ( h\right )=2m

Now velocity of jet at height of 2m

v^2-u^2=2gh

v^2=15^2-2\left ( 9.81\right )\left ( 2\right )

v=\sqrt{185.76}=13.62 m/s

Now\ forces\ on\ plate\ are\ weight\left ( Downward\right ) and jet\ force\left ( upward\right )

equating them

W=\left ( \rho Av\right )v

W=10^{3}\times \frac{\pi}{4}\left ( 0.02\right )^2\times 13.62^2

W=58.28 N

7 0
3 years ago
Describe each occupation
vitfil [10]

Answer:

Carpenter — A carpenter is someone who works with wood. They build houses and make cabinets etc.

Logging —  Loggers are people who cut trees. They use strong chain saws to cut trees.

Shipwrights — Shipwrights build, design, and repair all sizes of boats.

Wood Machinist — Wood Machinists repair and cut timber or any kind of wood for construction projects. They also operate woodworking machines, as their name suggest.

Furniture finishers —  Furniture finishers shape, decorate, and restore damaged and worn out furniture.

5 0
3 years ago
Compare the use of a low-strength, ductile material (1018 CD) in which the stress-concentration factor can be ignored to a high-
kicyunya [14]

Answer:

Step 1 of 3

Case A:

AISI 1018 CD steel,

Fillet radius at wall=0.1 in,

Diameter of bar

From table deterministic ASTM minimum tensile and yield strengths for some hot rolled and cold drawn steels for 1018 CD steel

Tensile strength

Yield strength

The cross section at A experiences maximum bending moment at wall and constant torsion throughout the length. Due to reasonably high length to diameter ratio transverse shear will be very small compared to bending and torsion.

At the critical stress elements on the top and bottom surfaces transverse shear is zero

Explanation:

See the next steps in the attached image

5 0
3 years ago
Other questions:
  • A circuit-switching scenario in whichNcs users, each requiring a bandwidth of 25 Mbps, must share a link of capacity 150 Mbps.
    12·1 answer
  • To cool a summer home without using a vapor compression refrigeration cycle, air is routed through a plastic pipe (k=0.15 W/m*K,
    15·1 answer
  • Explain in detail the difference between the microstructures of a cold worked sample and Recrystallized sample ?
    15·1 answer
  • Write a single statement that prints outsideTemperature with 2 digits in the fraction
    8·1 answer
  • The manufacturer of a 1.5 V D flashlight battery says that the battery will deliver 9 mA for 40 continuous hours. During that ti
    11·1 answer
  • Compute the electrical resistivity of a cylindrical silicon specimen 7.0 mm (0.28 in.) diameter and 57 mm (2.25 in.) in length i
    9·1 answer
  • What is the scope of hazard review in a worksite analysis
    7·1 answer
  • A spherical metal ball of radius r_0 is heated in an oven to a temperature of T_1 throughout and is then taken out of the oven a
    6·1 answer
  • 10. True or False? A disruptive technology<br> radically changes the way people live and<br> work.
    5·2 answers
  • Engineering problems and it solutions it machine design​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!