Okay here's what I have... but my test cases when running the program are not allowing me to input negative, decimal, or exponents as temperatures. I know it something small but it's alluding me, I figured if I had F and C as double it would work. Any ideas?
Another problem I seem to have (though very minor) is limiting the amount of numbers in a remainder to just the tenths place. Say you input 64°F and you convert to C, it comes out as 17.77777777777778°C. Like I said it's not a major problem, it just looks neat.
Thanks!
import java.util.Scanner;
public class Main {
double fahrenheit;
double celsius;
int choice;
Scanner input = new Scanner(System.in);
public void mainMenu(){
System.out.print("Welcome to the Fahrenheit to Celsius Converter!\n");
System.out.println("Select from the following menu options below:\n");
System.out.println("========================");
System.out.println("| [1] F to C |");
System.out.println("| [2] C to F |");
System.out.println("| [3] Exit |");
System.out.println("========================");
System.out.print("Please select your option now:");
choice =input.nextInt();
if(choice == 1){
System.out.println("You have selected F to C.");
System.out.print("Enter in the temperature: ");
fahrenheit = input.nextInt();
celsius = (5.0/9)*(fahrenheit - 32);
System.out.println("The conversion is " + celsius + "\u00B0" + "C.");
}
else if(choice == 2){
System.out.print("You have selected C to F.");
System.out.print("Enter in the temperature: ");
celsius = input.nextInt();
fahrenheit = (9.0/5)*(celsius + 32);
System.out.println("The conversion is " + fahrenheit + "\u00B0" + "F.");
}
}
public static void main(String[] args) {
new Main().mainMenu();
}
}