We have a steam heating boiler whose bursting pressure is known, but we of course want to use it only at pressures well below this limit. Our engineers recommend a safety factor of 2; that is, we should never exceed a pressure that is half of the rated bursting pressure. Write a java program that reads in the rated bursting pressure and the current pressure, and determines if the boiler is operating at a safe pressure.
Write a java program that reads in the rated bursting pressure and the current pressure, and determines if the boiler is operating at a safe pressure. For example: Enter the rated bursting pressure of the boiler (psi): 621 Enter the current pressure (psi): 137.8 The maximum safe pressure is 310.5 psi. The current pressure is safe. or Enter the rated bursting pressure of the boiler (psi): 625 Enter the current pressure (psi): 450 The maximum safe pressure is 310.5 psi. WARNING! The current pressure is not safe. Hint: Use three variables: burst_psi current_psi, and max_safe_psi
Answer:
Here is the java code:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
System.out.print("Enter the rated
bursting pressure of the boiler (psi): ");
double burst_psi =
sc.nextDouble();
System.out.print("Enter the current
pressure (psi): ");
double current_psi =
sc.nextDouble();
double max_safe_psi =
burst_psi/2;
System.out.println("The maximum
safe pressure is "+max_safe_psi+" psi.");
if(current_psi>max_safe_psi)
{
System.out.println("WARNING! The
current pressure is not safe.");
}
else
{
System.out.println("The current
pressure is safe.");
}
}
}
Output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
We have a steam heating boiler whose bursting pressure is known, but we of course want...
Write a java program that reads in the rated bursting pressure and the current pressure, and determines if the boiler is operating at a safe pressure. For example: Enter the rated bursting pressure of the boiler (psi): 625 Enter the current pressure (psi): 137.8 The maximum safe pressure is 208.3 psi. The current pressure is safe. or Enter the rated bursting pressure of the boiler (psi): 625 Enter the current pressure (psi): 250 The maximum safe pressure is 208.3 psi....