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 179 ‑turn circular coil of radius 3.95 cm and negligible resistance is immersed in a uniform magnetic field that is perpendicu
suter [353]

Answer:

The energy, that is dissipated in the resistor during this time interval is 153.6 mJ

Explanation:

Given;

number of turns, N = 179

radius of the circular coil, r = 3.95 cm = 0.0395 m

resistance, R = 10.1 Ω

time, t = 0.163 s

magnetic field strength, B = 0.573 T

Induced emf is given as;

emf= N\frac{d \phi}{dt}

where;

ΔФ is change in magnetic flux

ΔФ  = BA = B x πr²

ΔФ  = 0.573 x π(0.0395)² = 0.002809 T.m²

emf = N\frac{d \phi}{dt} = 179(\frac{0.002809}{0.163} ) = 3.0848 \ V

According to ohm's law;

V = IR

I = V / R

I = 3.0848 / 10.1

I = 0.3054 A

Energy = I²Rt

Energy = (0.3054)² x 10.1 x 0.163

Energy = 0.1536 J

Energy = 153.6 mJ

Therefore, the energy, that is dissipated in the resistor during this time interval is 153.6 mJ

6 0
3 years ago
Select the correct answer.
olya-2409 [2.1K]

Answer:

screw is the answer of the question

6 0
3 years ago
Read 2 more answers
Steam enters an adiabatic condenser (heat exchanger) at a mass flow rate of 5.55 kg/s where it condensed to saturated liquid wat
Evgen [1.6K]

Answer:

The minimum mass flow rate will be "330 kg/s".

Explanation:

Given:

For steam,

m_{s}=5.55 \ kg/s

\Delta h=2491 \ kg/kj

For water,

\Delta T=10^{\circ}C

(Cp)_{w}=4.184 \ kJ/kg^{\circ}C

They add energy efficiency as condenser becomes adiabatic, with total mass flow rate of minimal vapor,

⇒  m_{s}\times (\Delta h)=M_{w}\times(Cp)_{w}\times \Delta T

On putting the estimated values, we get

⇒  5.55\times 2491=M_{w}\times 4.184\times 10\\

⇒  13825.05=M_{w}\times 41.84

⇒  M_{w}=330 \ kg/s

7 0
3 years ago
In the fully developed region of flow in a circular pipe, does the velocity profile change in the flow direction?
taurus [48]

Answer:

<em>No, the velocity profile does not change in the flow direction.</em>

Explanation:

In a fluid flow in a circular pipe, the boundary layer thickness increases in the direction of flow, until it reaches the center of the pipe, and fill the whole pipe. If the density, and other properties of the fluid does not change either by heating or cooling of the pipe, <em>then the velocity profile downstream becomes fully developed, and constant, and does not change in the direction of flow.</em>

3 0
3 years ago
A discrete MOSFET common-source amplifier has RG = 2 MΩ, gm = 5 mA/V, ro = 100 kΩ, RD = 20kΩ, Cgs = 3pF, and Cgd = 0.5pF. The am
Papessa [141]

Answer:

a) -36.36 V/V

b) 15.17 kHz

c) 1.6 GHz

Explanation:

See attached picture.

7 0
3 years ago
Other questions:
  • A rod is 2m long at temperature of 10oC. Find the expansion of the rod, when the temperature is raised to 80oC. If this expansio
    7·1 answer
  • Vehicles arrive at a single toll booth beginning at 8:00 A.M. They arrive and depart according to a uniform deterministic distri
    9·1 answer
  • When a conductor is moved in a magnetic field, a voltage will be induced on the conductor. However, current won't flow through t
    11·1 answer
  • Exhaust gases entering a convergent nozzle have a total pressure (Pt) of 200 kPa and total temperature (Tt) of 800 K. The gases
    5·2 answers
  • In order to break even, your minimum selling price must be __________ your variable costs.
    10·1 answer
  • The x component of velocity in an incompressible flow field is given by u = Ax, where A = 2 s-1 and the coordinates are measured
    10·1 answer
  • Steven is starting a project that requires a specialized, experienced contractor. Which selection process is the most suitable f
    11·1 answer
  • Which of the following is a purpose of sports biomechanics?
    14·1 answer
  • What document should you have from the engine manufacturer when working on an engine
    8·1 answer
  • Using the tables for water, determine the specified property data at the indicated states. In each case, locate the state on ske
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!