How can I convert to different measurement systems if I can't create another UNIT field to understand which system I need to convert to?
class Temperature{
private final double tm;
Temperature(double tm, char unit) {
this.tm = tm;
}
public double getInC(){
}
public double getInF(){
}
public double getInK(){
}
}
public class Temperatures {
public static void main(String[] args) {
Temperature t1 = new Temperature(25, 'C');
System.out.printf("C: %6.2f%n", t1.getInC());
System.out.printf("F: %6.2f%n", t1.getInF());
System.out.printf("K: %6.2f%n", t1.getInK());
Temperature t2 = new Temperature(77, 'F');
System.out.printf("C: %6.2f%n", t2.getInC());
System.out.printf("F: %6.2f%n", t2.getInF());
System.out.printf("K: %6.2f%n", t2.getInK());
Temperature t3 = new Temperature(298.15, 'K');
System.out.printf("C: %6.2f%n", t3.getInC());
System.out.printf("F: %6.2f%n", t3.getInF());
System.out.printf("K: %6.2f%n", t3.getInK());
}
}
Idk what to do about the fact that I can't create another field