//Define a new class named Temperature. The class has two //accessors— to- Fahrenheit and toCelsius— that return the //temperature in the specified unit and two mutators— //setFahrenheit and setCelsius— that assign the temperature //in the specified unit. Maintain the temperature internally in //degrees Fahrenheit. Using this class, write a program that //inputs temperature in degrees Fahrenheit and outputs the //temperature in equivalent degrees Celsius. public class Temperature { private double tempF; private double tempC; public Temperature(double tempF,double tempC){ this.tempF = tempF; this.tempC = tempC; } public void setTempF(double tempF) { this.tempF = tempF; } public void setTempC(double tempC) { this.tempC = tempC; } public double toTempF() { return tempF = (9/5) * tempC + 32; } public double toTempC() { return tempC = (5/9) * (tempF - 32); } }
This is my main method -not complete- , also which I'm stuck on.
public class C4Q7 { public static void main(String[] args) { Temperature celcius, fahrenheit; fahrenheit = new Temperature(); fahrenheit.setTempF(93.89); celcius = new Temperature(); celcius.setTempC(32); } }