Celcius to Farenheit Conversion Java Program Solution

Question:-

Write a program to convert  Celsius to Farenheit.  Display the result correct to 1 decimal.

Create a class “CelsiusConversion.java” and write the main method.

Hint : 5 * (F – 32) = 9 * C,  F-Farenheit , C- Celsius

Sample Input  1 :

80

Sample Output  1 :

176.0

Sample Input  2 :

88

Sample Output  2 :

190.4

Code:-

import java.util.*;
class CelsiusConversion{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        float c = sc.nextFloat();
        float F= c*(9f/5) + 32;
        System.out.println(String.format("%.1f",F));
    }
}

Leave a Comment

Scroll to Top