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
A 2-m^3 rigid tank contains nitrogen gas at 500kPa and 300K. Now the gas is compressed isothermally to a volume of 0.1 m. The wo
stira [4]

Answer:

(d) 2996 kJ

Explanation:

We have given initial volume v_1=2m^3

initial pressure p_1=500\ kPa

initial temperature T_1=300\ K

we know that during  isothermal process the work done is given by

W=p_1v_1ln\frac{v_2}{v_1}

where v_2= final\ volume =0.1m^3\ given

putting all these value in formula of work done

W=500\times 2\times ln\frac{0.1}{2}

=-2995.8 kJ here negative sign indicates that work is dine on the gas

so wok done =2995.8 kJ

8 0
3 years ago
Explain the Corona discharge?​
rosijanka [135]

Answer:

• Corona discharge means <u> </u><u>neutralization</u><u> </u><u>of</u><u> </u><u>charge</u><u> </u><u>action</u><u> </u><u>at</u><u> </u><u>a</u><u> </u><u>sharp</u><u> </u><u>point</u>

example; a pear shaped conductor, lightening conductor, van de graaf generator.

Explanation:

• In corona discharge, When a sharp conductor is placed somewhere in open space. The charges of opposite chrage attract the opposite ions in the air around that conductor.

• This increases the charge density and electric field intensity at the sharp point, this neutralises the charge at sharp point hence a discharge known as corona discharge occurs.

.

8 0
3 years ago
7. You sometimes service vehicles with rust damage. It's safe to lift them on a two-post,
solong [7]

You sometimes service vehicles with rust damage. It's safe to lift them on a two-post frame-engaging lift without checking the vehicle lifting points. This is false.

<h3>What is rust?</h3>

Rust is an iron oxide, a typically reddish-brown oxide created when iron and oxygen react catalytically with moisture from the air or water. Iron(III) oxide-hydroxide and hydrous iron(III) oxides make up rust, which is often linked to the corrosion of refined iron.

Rusting is the chemical process that causes a red or orange coating to form on the surface of metals. Corrosion incorporates rusting. Steel and iron rust when they come into contact with oxygen and water, which are both necessary for rusting to take place.

It should be noted that when servicing vehicles with rust damage, It's not safe to lift them on a two-post frame-engaging lift without checking the vehicle lifting points. This can cause an accident.

Learn more about rust on:

brainly.com/question/1477535

#SPJ1

You sometimes service vehicles with rust damage. It's safe to lift them on a two-post frame-engaging lift without checking the vehicle lifting points.

True

False

8 0
2 years ago
HELP PLS
Angelina_Jolie [31]

Answer:

The correct option is;

B) Metamorphic Rocks

Explanation:

Zoisite, which is also referred to saualpite, is a metamorphic rock which is a hydroxy sorosilicate mineral formed from other types of rocks such as sedimentary, metamorphic and ingenious rocks in the process of their metamorphism under the presence high temperatures and pressures and mineral fluids which are hot

Zoiste is named after Sigmund Zois by Abraham Gottlob Werner in 1805 when Sigmund Zois sent Abraham Gottlob Werner the mineral specimen from Saualpe in 1805

6 0
3 years ago
The system use to complete this drawing called as_____​
Andreyy89

Answer:

Technical drawing

Explanation:

The drawings reflect what the project specifications are unlikely to cover

6 0
3 years ago
Other questions:
  • Air is compressed adiabatically from p1 1 bar, T1 300 K to p2 15 bar, v2 0.1227 m3 /kg. The air is then cooled at constant volum
    13·1 answer
  • Unlike in previous questions where we wanted you to complete a function we had started, here we want you to write a Python funct
    5·1 answer
  • Consider a turbojet powered airplane flying at a standard altitude of 30,000ft at a velocity of 500 mph. The turbojet engine its
    13·1 answer
  • Ayden read 84 pages in 2 hours. At that rate, how many pages can he read in 5 hours
    11·2 answers
  • Which of these is NOT a function of Shock Absorbers?
    15·2 answers
  • Chegg Discuss why stress-strain behavior of material is critical than just the ultimate strength of the material. What propertie
    9·1 answer
  • SE DEBE CONTRUIR UNA PARED QUE TENDRÁ 4 METROS DE LARGO POR 3 METROS
    11·1 answer
  • Air enters a control volume operating at steady state at 1.2 bar, 300K, and leaves at 12 bar, 440K, witha volumetric flow rate o
    11·1 answer
  • Will give brainly
    13·2 answers
  • Which of the following scenarios describes an advantage of a global economy?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!