i need to move
if(fright <= 45 && fright >= 35)
System.out.println("Pressure is in range");
else
System.out.println("Warning: Front right tire pressure is out of range");
to TirePressure but have it still print out right after i imput the tires pressure not after i imput them all and i cant figure out how to do it.
public class TirePressure
{
private int fright = 0;
private int bright = 0;
private int fleft = 0;
private int bleft = 0;
public TirePressure(int w, int x, int y, int z)
{
fright = w;
fleft = x;
bright = y;
bleft = z;
}
public String checkFP()
{
String message;
if(bleft <= bright && fleft == fright && fright >= 35 && fright <= 45 && bright >= 35 && bright <= 45)
//if(bleft == bright ||bright == bleft + 3 || bright == bleft - 3 || bright == bleft + 2 || bright == bleft - 2 || bright == bleft + 1 || bright == bleft - 1 )
{
message = "Back inflation is OK.";
}
else
message = "Back inflation is Not ok.";
return message;
}
public String checkBP()
{
String message;
if( fright == fleft ||fright == fleft -3 || fright == fleft +3 || fright == fleft - 2 || fright == fleft + 1 || fright == fleft - 1 )
{
/message = " inflation is OK.";
}
else
message = " inflation is NOT ok.";
return message;
}
}
import java.util.Scanner;
public class TirePressureTester
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter Your Right Front Tire Pressure");
int fright = keyboard.nextInt();
if(fright <= 45 && fright >= 35)
System.out.println("Pressure is in range");
else
System.out.println("Warning: Front right tire pressure is out of range");
System.out.println("Enter Your Left Front Tire Pressure");
int fleft = keyboard.nextInt();
if(fleft <= 45 && fleft >= 35)
System.out.println("Pressure is in range");
else
System.out.println("Warning: Front left tire pressure is out of range");
System.out.println("Enter Your Right Back Tire Pressure");
int bright = keyboard.nextInt();
if(bright <= 45 && bright >= 35)
System.out.println("Pressure is in range");
else
System.out.println("Warning: Back right tire pressure is out of range");
System.out.println("Enter Your Left Back Tire Pressure");
int bleft = keyboard.nextInt();
if(bleft <= 45 && bleft >= 35)
System.out.println("Pressure is in range");
else
System.out.println("Warning: Back left tire pressure is out of range");
TirePressure set1 = new TirePressure(fright, fleft, bright, bleft);
System.out.println("" + set1.checkFP());
}
}