This is a strange issue:
So when I choose 1 for Farenheit it will prompt me to enter the Farenheit value.
It will then go the FarenHeitToCelcius method. For some reason the celcius is always returning 0.0
Any kind of help would be greatly appreciated
package Exercises;
import java.util.Scanner;
public class TemperatureCOnversion {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("Enter 1 to return Celcius or 2 for Farenheit: ");
System.out.println("Your CHOICE: ");
int choice = input.nextInt();
switch(choice){
case 1:
System.out.println("Enter the Fareheit for celcius calculation: ");
double farenheit = input.nextDouble();
System.out.println(farenheit);
double celcius_result = FarenHeitToCelcius(farenheit);
System.out.println(celcius_result);
break;
case 2:
System.out.println("Enter the Celcius for Farenheit calculation: ");
double celcius1 = input.nextDouble();
double farenheit_result = CelciusToFarenheit(celcius1);
break;
default:
System.out.println(" **********Invalid Entry ******");
break;
}
}
public static double FarenHeitToCelcius(double f){
//double celcius = 0;
double celcius = (5/9)*(f -32);
System.out.println(" The equivalent celcius temperature is: " + celcius);
return celcius;
}
public static double CelciusToFarenheit(double c){
double farenheit =( (9/5*c) + 32);
System.out.println(" The equivalent fareheit temperature is: " + farenheit);
return farenheit;
}
}