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
Please help, Artificial Intelligence class test
MrRissso [65]

The answer to your quesition is b

4 0
2 years ago
An ideal reheat Rankine cycle with water as the working fluid operates the boiler at 15,000 kPa, the reheater at 2000 kPa, and t
solniwko [45]

Answer:

See the explanation below.

Explanation:

First find the enthalpies h₁, h₂, h₃, h₄, h₅, and h₆.

Find h₁:

Using Saturated Water Table and given pressure p₁ = 100 kPa

h₁ = 417.5 kJ/kg

Find h₂:

In order to find h₂, add the w_{p} to h₁, where  w_{p}  is the work done by pump and h₁ is the enthalpy computed above h₁ = 417.5 kJ/kg.

But first we need to compute  w_{p} To computer  

Pressures:

p₁ = 100 kPa

p₂ = 15,000 kPa

and

Using saturated water pressure table, the volume of water v_{f} = 1.0432

Dividing 1.0432/1000 gives us:

Volume of water = v₁ =  0.001043 m³/kg

Compute the value of h₂:

h₂ = h₁ + v₁ (p₂ - p₁)

    = 417.5 kJ/kg + 0.001043 m³/kg ( 15,000 kPa - 100 kPa)

    =  417.5 + 0.001043 (14900)

    = 417.5 + 15.5407

    = 433.04 kJ/kg

Find h₃  

Using steam table:

At pressure p₃ = 15000 kPa

and Temperature = T₃ = 450°C

Then h₃ = 3159 kJ/kg

The entropy s₃ = 6.14 kJ/ kg K

Find h₄

Since entropy s₃ is equal to s₄ So

s₄ = 6.14 kJ/kgK

To compute h₄

s₄ = s_{f} + x_{4} s_{fg}

x_{4} = s_{4} -s_{f} /s_{fg}

x_{4} = 6.14 -  2.45 / 3.89

x_{4}   = 0.9497

The enthalpy h₄:

h₄ = h_{f} +x_{4} h_{fg}

    = 908.4 + 0.9497(1889.8)

    =  908.4 + 1794.7430

    = 2703 kJ/kg

This can simply be computed using the software for steam tables online. Just use the entropy s₃ = 6.14 kJ/ kg K and pressure p₄ = 2000 kPa

Find h₅

Using steam table:

At pressure p₅ = 2000 kPa

and Temperature = T₅ = 450°C

Then h₅  = 3358 kJ/kg

Find h₆:

Since the entropy s₅ = 7.286 kJ/kgK is equal s₆ to  So

s₆ = 7.286 kJ/kgK = 7.29 kJ/kgK

To compute h₆

s₆ = s_{f} + x_{6} s_{fg}

x_{6} = s_{6} -s_{f} /s_{fg}

x_{6} = 7.29 - 1.3028 / 6.0562

x_{6}   = 0.988

The enthalpy h₆:

h₆ = h_{f} +x_{6} h_{fg}

    = 417.51 + 0.988 (2257.5)

    = 417.51 + 2230.41

  h₆ =  2648 kJ/kg

This can simply be computed using the software for steam tables online. Just use the entropy s₅ = 7.286 kJ/kgK and pressure p₅ = 2000 kPa

Compute power used by pump:

P_{p} is found by using:

mass flow rate = m =  1.74 kg/s

Volume of water = v₁ =  0.001043 m³/kg

p₁ = 100 kPa

p₂ = 15,000 kPa

P_{p}  = ( m ) ( v₁ ) ( p₂ - p₁ )

     = (1.74 kg/s) (0.001043 m³/kg) (15,000 kPa - 100 kPa)

     = (1.74 kg/s) (0.001043 m³/kg) (14900)

     = 27.04

P_{p} = 27 kW

Compute heat added q_{a} and heat rejected q_{r}  from boiler using computed enthalpies:

q_{a} = ( h₃ - h₂ ) + ( h₅ - h₄ )

      = ( 3159 kJ/kg - 433.04 kJ/kg ) + ( 3358 kJ/kg - 2703 kJ/kg )

      = 2726 + 655

      = 3381  kJ/kg

q_{r} =  h₆ - h₁

  = 2648 kJ/kg - 417.5 kJ/kg

  = 2232 kJ/kg

Compute net work

W_{net} = q_{a} - q_{r}

       = 3381  kJ/kg - 2232 kJ/kg

       = 1150 kJ/kg

Compute power produced by the cycle

mass flow rate = m =  1.74 kg/s

W_{net} = 1150 kJ/kg

P = m * W_{net}

  = 1.74 kg/s * 1150 kJ/kg

  = 2001 kW

Compute rate of heat transfer in the reheater

Q = m * ( h₅ - h₄ )

   =  1.74 kg/s * 655

   =  1140 kW

Compute Thermal efficiency of this system

μ_{t} = 1 - q_{r} /  q_{a}

   = 1 - 2232 kJ/kg / 3381  kJ/kg

   = 1 - 0.6601

   = 0.34

   = 34%

7 0
3 years ago
Design for human-fit strategies include:
andreev551 [17]

Answer:

B- extreme fit, close fit, adjustable fit

Explanation:

A human-fit design typically involves the process of manufacturing or producing products (tools) that are easy to use by the end users. Therefore, human-fit designs mainly deals with creating ideas that makes the use of a particular product comfortable and convenient for the end users.

The design for human-fit strategies include; extreme fit, close fit and adjustable fit.

Hence, when the aforementioned strategies are properly integrated into a design process, it helps to ensure the ease of use of products and guarantees comfort for the end users.

5 0
2 years ago
A series AC circuit contains a resistor, an inductor of 250 mH, a capacitor of 4.40 µF, and a source with ΔVmax = 240 V operatin
slega [8]

Answer:

Explanation:

Inductance = 250 mH = 250 / 1000 = 0.25 H

capacitance = 4.40 µF = 4.4 × 10⁻⁶ F ( µ = 10⁻⁶)

ΔVmax = 240, f frequency = 50Hz and I max = 110 mA = 110 /1000 = 0.11A

a) inductive reactance = 2πfl =  2 × 3.142 × 50 × 0.25 H =78.55 ohms

b) capacitive reactance = \frac{1}{2\pi fC} = 1 / ( 2 × 3.142× 50 × 4.4 × 10⁻⁶ ) = 723.34 ohms

c) impedance = \frac{Vmax}{Imax} = 240 / 0.11 = 2181.82 ohms

7 0
3 years ago
Read 2 more answers
List and describe three classifications of burns to the body.
DiKsa [7]

AnswerWhat Are the Classifications of Burns? Burns are classified as first-, second-, or third-degree, depending on how deep and severe they penetrate the skin's surface. First-degree burns affect only the epidermis, or outer layer of skin. The burn site is red, painful, dry, and with no blisters.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • g (d) Usually, in the case of two finite-duration signals like in parts (a) and (b), the convolution integralmust be evaluated i
    7·1 answer
  • What is the heat flux (W/m2) to an object when subjected to convection heat transfer environment given: 24 °C = the surface temp
    10·1 answer
  • A turboprop engine consists of a diffuser, compressor, combustor, turbine, and nozzle. The turbine drives a propeller as well as
    12·1 answer
  • Compute the volume percent of graphite, VGr, in a 3.2 wt% C cast iron, assuming that all the carbon exists as the graphite phase
    8·1 answer
  • How may a Professional Engineer provide notice of licensure to clients?
    9·1 answer
  • Products. of sheet metal​
    8·1 answer
  • ENERGIA
    7·1 answer
  • What do you understand by the term phase angle?<br>​
    13·1 answer
  • All of the following are drum brake components mounted to the backing plate, EXCEPT:
    12·1 answer
  • It is acceptable to mix used absorbents.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!