In this tutorial, we will see simple java program to convert celsius to fahrenheit in java.
You can convert celsius to fahrenheit using this formula.
fh = (1.8*cen) + 32;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import java.util.Scanner; public class TempConvertor { public static void main(String args[]) { float cen; double fh; Scanner scanner = new Scanner(System.in); System.out.print("Enter Temperature in Centigrade : "); cen = scanner.nextFloat(); fh = (1.8*cen) + 32; System.out.print("Equivalent Temperature in Fahrenheit = " + fh); } } |
Output:
Enter Temperature in Centigrade : 30
Equivalent Temperature in Fahrenheit = 86.0
Equivalent Temperature in Fahrenheit = 86.0
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.