public class DegConv { public static void main (String [] args) { String action; int result; while(true) { action = IBIO.readString("Conv to(C/F/q): "); if (action.equal("q") || action.equal("Q")) break; result = conv(IBIO.readInt("Temperature: "), choose(action)); if (result == -1) { System.out.println("Wrong type."); } else { System.out.println(result); } } public static int choose (String input){ switch (input) { case "c": case "C": return 0; case "f": case "F": return 1; default: return -1; } } public static int conv (int temp, int type) { switch (type) { case 0: return 5*(temp - 32)/9; case 1: return (9*temp/5)+32; default: return -1; } } }