Java Celcius to Farenheit Conversion Program in java

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.Scanner;


public class CelsiusConversion
{
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        double cel=sc.nextDouble();
        double fah=((9*cel)/5)+32;
        System.out.println(fah);
    }
}

Leave a Comment

Scroll to Top