I have written this program and I have gotten the program to run but when I run the program and I try to run the input validation portion it does not go back into the loop. Also when I calculate celsius into farenheit my output comes out to 0.
Is there any way you can help me figure this problem out?
Thank You in Advance :lol:
/**********************************************
* DegreesConverter.java
*
*
* This program converts either from degrees
* Celsius to Farenheit or degrees Farenheit
* to Celsius.
* *********************************************/
public class DegreesConverter
{
public static void main (String [] args)
{
double celsius;
double farenheit;
double temp;
char degrees;
char response = 'Y';
System.out.print("Enter a temperature: ");
temp = Input.readDouble ();
while (response == 'Y')
{
System.out.print("Enter a C for Celsius or an F for Farenheit: ");
degrees = Input.readChar ();
if((degrees == 'C') || (degrees == 'c'))
{
farenheit = 9/5 * (temp) + 32;
System.out.println("Temperature = " +temp + 'C');
System.out.println("Temperature in Farenheit = " +farenheit +'F');
}
else if ((degrees == 'F') || (degrees == 'f'))
{
celsius = 5/9 * (temp - 32);
System.out.println("Temperature = " +temp + 'F');
System.out.println("Temperature in Celsius = " +celsius + 'C');
}
else
{
System.out.println("Invalid Entry");
//System.out.println("You entered" +degrees);
System.out.println("Enter a temperature followed by a C for Celsius or F for Farenheit");
System.out.print("Enter a temperature: ");
temp = Input.readDouble ();
System.out.print("Enter a C for Celsius or an F for Farenheit: ");
degrees = Input.readChar ();
}
System.out.print("Would you like to enter another temperature? Y or N: ");
response = Input.readChar ();
//System.out.print("Enter a temperature: ");
//temp = Input.readDouble ();
}
} // End Main
} // End Class DegreesConverter