Need help please. This program is supposed to be a do while loop and convert fahrenheit to celcius and vise versa using user defined methods but as of right now it just doesn't work. I need to make a do while loop in main method too, but was just trying to link the user entered letters but that doesn't seem to be working either. Can someone point me in the right direction please,
import java.util.*;
public class p7
{
static Scanner kb = new Scanner(System.in);
public static void main(String[] args)
{
char letter, C, F, Q;
int cel,fah, fahrenheit, celsius;
displayMenu();
if(letter == 'C')
{
celToFar();
}
else if (letter == 'F')
{
farToCel();
}
else (letter == 'Q');
{
System.Exit(0);
}
displayMenu();
}
public static char displayMenu()
{
do
{
char letter, C, F, Q;
letter = kb.next().charAt(0);
System.out.println("Please select one of the following: \n");
System.out.println("\tF - to convert Fahrnheit to Celsius ");
System.out.println("\tC - to convert Celsius to Fahrnheit\n");
System.out.println("\tQ - to Quit.");
System.out.printf("%nChoice:");
}
while(letter.toUpperCase() == 'C' || letter.toUpperCase() == 'F' || letter.toUpperCase() == 'Q');
}
public static int celToFar()
{
do
{
System.out.println("Please enter the Celsius temperature:");
cel = kb.nextInt();
celsius = (cel) * 9 / 5 + 32;
System.out.println("The temperature " + cel + " Celsius is " + celsius + "Fahrenheit.");
}
while(letter.toUpperCase() != 'F');
}
public static int farToCel()
{
do
{
System.out.println("Please enter the Fahrenheit temperature:");
fah = kb.nextInt();
fahrenheit = ((fah) - 32) * 5 / 9;
System.out.println("The temperature " + fah + " Fahrenheit is " + fahrenheit + " Celsius.");
}
while(letter.toUpperCase() != 'C');
}
}