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

6 comments:

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

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

    ReplyDelete
  3. This article is nicely written. A very well written guide to take care of your furnace.
    top seo services in lahore pakistan

    ReplyDelete
  4. Penthouse Apartment at Mabeyn Sahil is a unique apartment within the city that has outstanding sea view of the city. Contact Us for buying penthouse apartment in turkey.

    ReplyDelete
  5. No doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post visit my website for Buy Generic Viagra 200 Mg Online without prescription. Only $1 per pill. Free shipping . Approved online pharmacy. sildenafil 200

    ReplyDelete
  6. Very interesting, good job and thanks for sharing such a good blog and if you want to buy Valacyclovir 500 Mg Online without prescription. Only $1.25 Per Pill. Free shipping. Approved online pharmacy.Visit Please buy centrex 500mg tablets

    ReplyDelete