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
When designing a car that runs on wind or Air car . can you tell me the details for the following points Compressed Air Engine:
BabaBlast [244]

Answer:

a)

The crack and connecting rod is used in the design of car.This mechanism is known as slider -crank mechanism.

Components:

1.Inlet tube

2. Wheel

3. Exhaust

4. Engine

5.Air tank

6.Pressure gauge

7.Stand

8. Gate valve

b)

The efficiency of air engine is less as compare to efficiency of electric engine and this is not ecofriendly because it produce green house gases.These gases affect the environment.

c)

it can run around 722 km when it is full charge.

                                                                                                                                                     

5 0
3 years ago
A furnace wall composed of 200 mm, of fire brick. 120 mm common brick 50mm 80% magnesia and 3mm of steel plate on the outside. I
Liula [17]

Answer:

  • fire brick / common brick : 1218 °C
  • common brick / magnesia : 1019 °C
  • magnesia / steel : 90.06 °C
  • heat loss: 4644 kJ/m^2/h

Explanation:

The thermal resistance (R) of a layer of thickness d given in °C·m²·h/kJ is ...

  R = d/k

so the thermal resistances of the layers of furnace wall are ...

  R₁ = 0.200/4 = 0.05 °C·m²·h/kJ

  R₂ = 0.120 2.8 = 3/70 °C·m²·h/kJ

  R₃ = 0.05/0.25 = 0.2 °C·m²·h/kJ

  R₄ = 0.003/240 = 1.25×10⁻⁵ °C·m²·h/kJ

So, the total thermal resistance is ...

  R₁ +R₂ +R₃ +R₄ = R ≈ 0.29286 °C·m²·h/kJ

__

The rate of heat loss is ΔT/R = (1450 -90)/0.29286 = 4643.70 kJ/(m²·h)

__

The temperature drops across the various layers will be found by multiplying this heat rate by the thermal resistance for the layer:

  fire brick: (4543.79 kJ/(m²·h))(0.05 °C·m²·h/kJ) = 232 °C

so, the fire brick interface temperature at the common brick is ...

  1450 -232 = 1218 °C

For the next layers, the interface temperatures are ...

  common brick to magnesia = 1218 °C - (3/70)(4643.7) = 1019 °C

  magnesia to steel = 1019 °C -0.2(4643.7) = 90.06 °C

_____

<em>Comment on temperatures</em>

Most temperatures are rounded to the nearest degree. We wanted to show the small temperature drop across the steel plate, so we showed the inside boundary temperature to enough digits to give the idea of the magnitude of that.

5 0
3 years ago
What is the resultant force on one side of a 25cm diameter circular plate standing at the bottom of 3m of pool water?
Tom [10]

Answer:

F=1.47 KN

Explanation:

Given that

Diameter of plate = 25 cm

Height of pool h = 3 m

We know that force can be given as

F= P x A

P=ρ x g x h

Now by putting the values

P=1000 x 10 x 3

P= 30 KPa

A=\dfrac{\pi}{4}\times 0.25^2\ m^2

A=0.049\ m^2

F= 30 x 0.049 KN

F=1.47 KN

So the force on the plate will be 1.47 KN.

4 0
3 years ago
Match the following parts of a crane
trasher [3.6K]
It is auxillary sorry i couldn’t help it happens to the best of us
5 0
3 years ago
Which of the following is NOT a provision of the Agricultural Adjustment Act? insurance for farmers alternative energy programs
Arisa [49]

Answer:

Farm equipment

Explanation:

Most people have heard claims that the US government pays farmers not to grow crops. The Agricultural Adjustment Act is the legislation that started this program. It was the first “Farm Bill.” The current farm bill provides for the following:

Subsidies for farmers

Insurance for farmers

Price supports

Food assistance for economically challenged Americans (the largest portion of the Farm Bill)

Forestry conservation programs

Alternative energy programs.

4 0
3 years ago
Other questions:
  • a refrigerator uses refrigerant-134a as the working fluid and operates on the vapor-compression refrigeration cycle. the evapora
    10·2 answers
  • 3/194 The assembly of two 5‐kg spheres is rotating freely about the vertical axis at 40 rev/min with θ = 90°. If the force F whi
    9·1 answer
  • A strain gauge with a 5 mm gauge length gives a displacement reading of 1.25 um. Calculate the stress value given by this displa
    15·1 answer
  • The rainfall rate in a certain city is 20 inches per year over an infiltration area that covers 33000 acres. Twenty percent of t
    6·1 answer
  • 11. Technicians A and B are discussing
    12·1 answer
  • Find the value of P(-1.5≤Z≤2)
    12·1 answer
  • 50 points
    7·1 answer
  • Find the capacitance reactance of a 0.1 micro frequency capacitor 50Hz and at 200Hz​
    9·1 answer
  • What is the definition of insert view and why do we use it
    10·1 answer
  • ) If the blood viscosity is 2.7x10-3 Pa.s, length of the blood vessel is 1 m, radius of the blood vessel is 1 mm, calculate the
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!