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
Most motor vehicle crashes in Florida in 2016 occurred on
vlada-n [284]
Most Motor Vehicle catches in Florida in 2016 occurred on Motorcycles. Another option could be roads.
4 0
3 years ago
Read 2 more answers
Microchips found inside most electronic devices today are examples of what material A. Polymers B. Alloys C. Composites D. None
dedylja [7]

Answer: A

Explanation:

Microchips are made out of silicone witch is a polymer.

6 0
3 years ago
Read 2 more answers
A 75 ! coaxial transmission line has a length of 2.0 cm and is terminated with a load impedance of 37.5 j75 !. If the relative p
Cerrena [4.2K]

Answer:

4.26

Explanation:

The wavelength λ is given by:

\lambda=v/f=c/nf\\c=speed\ of\ light=3*10^8m/s,f=frequency=3*10^9Hz,n=permittivity=2.56\\\\\lambda=3*10^8/(2.56*3*10^9)=0.0625\ m\\

Phase constant (β) = 2π/λ

βl = 2π/λ × l

l = 2 cm = 0.02 m

βl = 2π/0.0625 × 0.02=2.01 rad = 115.3°

1 rad = 180/π degrees

Z_L=load\ impedance=37.5+j75\\\\Z_o=characteristic impedance = 75\ ohm\\\\\tilde {Z_L}=Z_L/Z_o=37.5+j75/75=0.5+j

\tilde {Z_{in}}=\frac{\tilde {Z_{L}}+jtan\beta l}{1+j\tilde {Z_{L}}tan\beta l}=\frac{0.5+j+jtan(115.2)}{1+j(0.5+j)tan(115.2)}=0.253-j0.274\\  \\Z_{in}=Z_o\tilde {Z_{in}}=75(0.253-j0.274)=19-j20.5\\\\\Gamma_L=\frac{Z_L-Z_0}{Z_L+Z_o}=\frac{37.5+j75-75}{37.5+j75+75}=0.62\angle 83^o\\\\\Gamma_{in}=\frac{Z_{in}-Z_0}{Z_{in}+Z_o}=\frac{19-j20.5-75}{19-j20.5+75}=0.62\angle -147^o\\\\VSWR=\frac{1+\rho}{1-\rho} =\frac{1+0.62}{1-0.62}=4.26

6 0
3 years ago
Technician A says that coolant freeze protection can be measured with a
Diano4ka-milaya [45]
Answer: Technician A, I think
4 0
3 years ago
Read 2 more answers
On the 74ls74 d flip-flop, the pr (preset) and clr (clear) inputs have a circle. what do these symbols mean?
guapka [62]
It mean o JJ the 7 to the J
5 0
2 years ago
Other questions:
  • A fluid has a dynamic viscosity of 0.048 Pa.s and a specific gravity of 0.913. For the flow of such a fluid over a flat solid su
    10·1 answer
  • The welding method that requires the operator to observe and only make corrections is
    6·2 answers
  • In the circuit below I 1=20mA V1=10 R1=400 R2=2000 R3=1000. Use node analysis to find R2
    14·1 answer
  • Calculate the differential pressure in kPa across the hatch of a submarine 320m below the surface of the sea. Assume the atmosph
    6·1 answer
  • Anyone know sebastian from bb
    8·1 answer
  • When we utilize a visualization on paper/screen, that visualization is limited to exploring: Group of answer choices Relationshi
    9·1 answer
  • A heat engine receives heat from a heat source at 1453 C and has a thermal efficiency of 43 percent. The heat engine does maximu
    11·1 answer
  • The air velocity in the duct of a heating system is to be measured by a Pitot-static probe inserted into the duct parallel to th
    13·1 answer
  • An air standard cycle with constant specific heats is executed in a closed system with 0.003 kg of air and consists of the follo
    15·1 answer
  • which of the following statements are true about client-side DNS? (Choose all that apply). a. If an APIPA address is assigned, t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!