Java Program For Temperature Conversion


Aim :- Write a Java Program That Converts from Celsius to Fahrenheit and Fahrenheit to Celsius.



Java Program :


import java.util.*;
class p4_3{
     public static void main(String args[])
     {
          convert c=new convert();
          float temp=c.ctof(50);
          System.out.println("The Celcius to Fahrenheit: "+c.ctof(50));
          System.out.println("The Fahrenheit to Celcius: "+c.ftoc(50));
     }
}
class convert{
     float ctof(float c)
     {
          return (c+32);
     }
     float ftoc(float f)
     float ftoc(float f)
     {
          return (f-32);
     }
}

Output : 





Post a Comment

2 Comments