I am attempting to run a program through my main() class in my CelsiusToFahrenheit.java file. I created a public class called CelsiusToFahrenheit and when the class receives a parameter of the type "double" it is supposed to take that input and run it through an algorithm that converts the Celsius number in to Fahrenheit. When I compile the code and input an integer the output doesn't reflect the algorithm assigned to tempOutput. Here is the code:
import java.util.Scanner;
public class CelsiusToFahrenheit {
public static double convertCelsiusToFahrenheit(double tempInput) {
double tempOutput = 0.0;
tempOutput = (tempInput * (9 / 5)) + 32;
return tempOutput;
}
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
double tempF = 0.0;
double tempC = 0.0;
System.out.println("Enter temperature in Celsius: ");
tempC = scnr.nextDouble();
tempF = convertCelsiusToFahrenheit(tempC);
System.out.print("Fahrenheit: ");
System.out.println(tempF);
scnr.close();
return;
}
}
Any given number I input for the tempC variable outputs tempC + 32 when it is supposed to multiply tempC by 1.8 and then add 32 to it. Where did I go wrong here?