Temperature Conversion using Methods

OliverE

Power member.
Reputation
0
Temperature Conversion using Methods

Convert Celsius to Fahrenheit and the back again using multiple methods in java.
This snippet of code is just to help you understand how to use methods as well as transferring variable values between them.

[java]
public class tempconv {
public static void main(String args[])
{
ctof();

}

public static void ctof()
{
float C, F;
C=12;
F=((C*9)/5)+32;
System.out.println(F);
ftoc(F);
}

public static void ftoc(float F)
{
float C;
C=(((F-32)*5)/9);
System.out.println(C);
}
}[/java]
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…