Java code to convert Fahrenheit to Celsius

Below is the java code to print and convert  Fahrenheit to Celsius.

import java.util.*;

class FahrenheitToCelsius {
    public static void main(String[] args) {
        float temperature;
        Scanner in = new Scanner(System.in);

        System.out.print("Enter the temperature in Fahrenheit: ");
        temperature = in.nextInt();

        temperature = (temperature - 32) * 5 / 9;
        System.out.println("Temperature in Celsius = " + temperature);
    }
}


Output:

Enter the temperature in Fahrenheit: 70
Temperature in Celsius = 21.11111

5 comments:

  1. but why do you need float temperature; and Scanner in = new Scanner(System.in); ??

    ReplyDelete
    Replies
    1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

      or learn thru JavaScript Online Training from India. Appreciating the persistence you put into your blog and detailed information you provide. Kindly keep blogging.

      Delete
  2. Really Nice Information,Thank You Very Much For Sharing.
    Web Development Company

    ReplyDelete
  3. I have read your blog its very attractive and impressive. I like it your blog.


    SEO Services in India SEO Company in India SEO Company in India

    Guaranteed SEO services Guaranteed SEO

    ReplyDelete
  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java EE Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete