Question: public class TemperatureConverter { public static void main ( String [ ] args ) { / / Declare the constants. final double MIN _ FAHRENHEIT

public class TemperatureConverter {
public static void main(String[] args){
// Declare the constants.
final double MIN_FAHRENHEIT =-459.67;
// Declare the variables.
double fahrenheit;
double convertedDegrees =0;
int tempScale;
String tempScaleStr="";
// Creating the Scanner object
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the temperature in Fahrenheit: ");
fahrenheit = keyboard.nextDouble(); // Set a breakpoint here
// Verify the user's input
if (fahrenheit < MIN_FAHRENHEIT){// first if-statement: Set a breakpoint here
System.out.print("The temperature must be greater than or equal to "+ MIN_FAHRENHEIT);
System.exit(0);
}
System.out.print (
"Enter the temperature scales you want to convert to:
"+
"1. Kelvin
"+
"2. Rankine
"+
"3. Reaumur
"+
"4. Celsius
"+
"Enter a temperature scale: ");
tempScale = keyboard.nextInt();
if (tempScale <1|| tempScale >4){// Second-if statement: Set a breakpoint here
System.out.println("Unknown temperature scale -"+
" cannot do calculation. Bye");
}
else {
if (tempScale ==1){// Set a breakpoint here
convertedDegrees =(fahrenheit -32)*5/9+273.15;
tempScaleStr="Kelvin";
} else if (tempScale ==2|| tempScale ==3){
convertedDegrees = fahrenheit +459.67;
tempScaleStr="Rankine";
} else if (tempScale ==3){
convertedDegrees =(fahrenheit -32)*4/9 ; // Set a breakpoint here
tempScaleStr="Reaumur";
} else {
convertedDegrees =(fahrenheit -32)*5/9; // Set a breakpoint here
tempScaleStr="Celsius";
}
System.out.println(fahrenheit +" degrees Fahrenheit is "+ convertedDegrees +" degrees "+ tempScaleStr +".");
}
keyboard.close();
}
How do I fix my code since I already try to debugg it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!