There are numerous problems with your code, but the first thing I’m going to do it format it:
class Temperature {
//Assign varriables to int
int factorC, factorF;
int celcius, ferenheit;
int getFactorC() { // Celsius
return factorC;
}
Temperature(int factorC, int factorF, int celcius, int ferenheit) {
this.factorC = factorC;
this.factorF = factorF;
this.celcius = celcius;
this.ferenheit = ferenheit;
}
void setFactorC() {
factorC = (9 / 5) * celcius + 32; //Calculate Celcius
}
int getFactorF() { // Fahrenheit
return factorF;
}
void setFactorF() {
factorF = (5 / 9) * ferenheit - 32; //Calculate Ferenheit
}
}
Quick tip:
9/5
is 1 and5/9
is 0. In Java, when you divide integers, you get an integer. You can replace that with9.0/5.0
and5.0/9.0
.