//Declaring Variables
String answer;
double fahrenheit;
double celsius;
//Title
c.println ("Temperature Conversion");
c.println ();
//Ask user input
c.println ("Do you want to enter the temperature in Fahrenheit? Or Celsius?");
answer = c.readString ();
//See if they enter Fahrenheit to perform F to C calculations
if (answer.equals ("Fahrenheit"))
{
c.print ("Enter degrees Fahrenheit: ");
fahrenheit = c.readDouble ();
celsius = (fahrenheit - 32.0) * 5.0 / 9.0;
c.print (fahrenheit +" fahrenheit is equal to ");
c.print (celsius,0,2 );
c.println (" celsius.");
}
//Or if they enter Celsius to perform C to F calculations
else if (answer.equals ("Celsius"))
{
c.print ("Enter degrees Celsius: ");
celsius = c.readDouble ();
fahrenheit = (celsius + 32.0) / 5.0 * 9.0;
c.print (celsius +" celsius is equal to ");
c.print (fahrenheit,0,2 );
c.println (" fahrenheit.");
}
//if they enter something else
else
{
c.println ("Cannot find this type of conversion.");
}