I used netbeans to create the program below. Everything seems to run fine except my "FtoC" function doesn't run. It just returns to the initial conversion question. Any hints???
package tempconverter; import java.util.Scanner; /** * * @author jessie */ public class TempConverter { static Scanner sc= new Scanner(System.in); public static void main(String[] args) { int cType = 0; int getCType = 0; System.out.println("Welcome to the Temperature Converter"); cType = getCType(); while (cType != 0){ if (cType == 1) { FtoC(); } else if (cType == 2) { CtoF(); } //else { //System.out.println("Illegal value: Please enter 1,2, or 0"); //} cType = getCType(); } System.out.println("Thanks for using the temperature converter"); }//end of main public static int getCType(){ int ct; do { System.out.print("Select Conversion Type (1=F to C, 2=C to F, 0=end)"); try { ct = sc.nextInt(); if (ct != 0 && ct != 1 && ct != 2){ System.out.println("Illegal value: must be an integer of 0,1, or 2"); } } catch (Exception e){ sc.next(); ct = -1; } }while (ct != 0 && ct != 2); return ct; } //end of getCType public static void FtoC() { double c,f; System.out.print("Enter your Fahrenheit temperature"); f = sc.nextDouble(); c = 5.0 / 9.0 * (f - 32.0); System.out.println("A Temp of " + f + " Fahrenheit converted to Celsius = " + c + "C"); } //end of FtoC public static void CtoF(){ double f,c; System.out.print("Enter your Celsius temperature"); c = sc.nextDouble(); f = 9.0 / 5.0 * c + 32.0; System.out.println("A Temp of " + c + " Celsius converted to Fahrenheit = " + f + "F"); }//end of CtoF }