202k views
2 votes
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. WARNING! The current pressure is not safe.

User Matahari
by
5.7k points

1 Answer

4 votes

Answer:

import java.io.*;

import java.util.Scanner;

class pressure {

public static void main (String[] args) {

Scanner press=new Scanner(System.in); //creating a scanner object.

System.out.println("Enter the current pressure(psi):");//printing the message.

float p=press.nextFloat();//taking input of the float.

System.out.println("The maximum safe pressure is 208.3 psi.");

if(p>208.3)//checking the pressure and printing the message.

{

System.out.println("WARNING! The current pressure is not safe");

}

else{

System.out.println("The current pressure is safe");

}

}

}

Enter the current pressure(psi):

290

The maximum safe pressure is 208.3 psi.

WARNING! The current pressure is not safe

Step-by-step explanation:

I have created a scanner class object press for taking the input.I have taken a float variable p for input.If the pressure entered by the user is greater than 208.3 psi then the pressure is not safe and if it is less than 208.3 then the pressure is safe.

User Alex Sexton
by
5.4k points