Write a Java class to represent a temperature The class has
Solution
import java.util.Scanner;
   
public class Temperature {
 
 double setC;
 Temperature (double setC){
 this.setC = setC;
 }
 
 double getC()
 {
 return setC;
 }
 
 public double getF()
 {
 return ((double)9.0/5.0 * (setC + 32)); // Fahrenheit calculation
 }
 
 public double getK()
 {
 return ((double)setC + 273.15);
 }
 
   
 public static void main(String[] args){
 
 Scanner sc = new Scanner(System.in);
 System.out.print(\"Please enter the initial temperature: \");
 double setC = sc.nextDouble();
 
 Temperature temp = new Temperature (setC);
 System.out.println(\"The current temperature in Celsius is: \" +temp.getC());
 System.out.println(\"The current temperature in Fahrenheit is: \" +temp.getF());
 System.out.println(\"The current temperature in Kelvin is: \" +temp.getK());
 }
 }
example:
Please enter the initial temperature: 23 The current temperature in Celsius is: 23.0 The current temperature in Fahrenheit is: 99.0 The current temperature in Kelvin is: 296.15

