temperature conversion

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius

In this article, we will discuss the title of  the “Write temperature conversion programs from Fahrenheit to Celsius”

In this post, we will learn how to write a program to convert Fahrenheit into Celsius (Using the user input ) and display the result on the screen.

Generally, we are using three temperature units Fahrenheit, Celsius, and Kelvin. Fahrenheit and Celsius are the measuring units in degrees as oF and oC respectively. In this article, we are discussing how to convert temperature units Fahrenheit into Celsius.
Kevin is an international unit in temperature measurement.

 

Formula 

F=C x 9/5 + 32

 

Algorithm

  • Declare  variables as double
  • Ask for input from the user
  • Apply the formula and calculate Celsius
  • Print the temperature in Celsius on the screen

 

Code to  Fahrenheit into Celsius

Convert Fahrenheit into  Celsius – Java

Java language

Program 1

//Java program to Convert Fahrenheit into Celsius
import java.util.Scanner;
public class Fahrenheit_To_Celsius
{
public static void main (String args[]){
//declaring variables
double fahre,cels; 
Scanner input=new Scanner(System.in);
System.out.print("Enter the value to Fahrenheit: ");
//Ask input rom the user
fahre=input.nextDouble();
//Reading the input
cels=(((fahre-32)*5)/9);
//Calculate Celsius value
  System.out.print("Temperature in Celsius:"+cels);
//print the result on the screen
}
}

When the above code is executed, it produces the following result

Enter the value to Fahrenheit: 104
Temperature in Celsius:40.0

 

Convert Fahrenheit into  Celsius – C

C language

Program 2

// C program to convert Temparature
// fahrenheit into celsius
#include <stdio.h>

int main() {
    //variable declaration
    float celsius,fahrenheit;
   //asking input from user
     printf("Enter the temperature in Fahrenheit :");
    scanf("%f",&fahrenheit);
  //Reading the input from the user
  
    //Convert fahrenheit into celsius
    celsius=((fahrenheit-32)*5/9);
  //Calculate Celsius value 
    printf("The temperature in Celsius is=%.2f ",celsius);

    return 0;
}

When the above code is executed, it produces the following result

Enter the temperature in Fahrenheit:70
The temperature in Celsius is=21.11

 

Convert Fahrenheit into  Celsius – C++

C++ language

Program 3

//C++ program to convert F into C
//Taking input
#include <iostream>
using namespace std;
int main() {
    float celsius, fehrenheit;
    //declaration of float type variables
    cout<<"Enter the temparature in fehrenheit:";
  // ask input from the user
  cin>>fehrenheit;//reading the input
    //Calculate Celsius
    celsius=((fehrenheit-32) * 5/9);
    cout<<fehrenheit<<" Fehrenheit is: "<<celsius <<" Celsius";
    //display result on the screen

    return 0;
}

When the above code is executed, it produces the following result

Enter the temparature in fehrenheit:200
200 Fehrenheit is: 93.3333 Celsius

 

Convert Fahrenheit into  Celsius – C#

C# language

Program 3

// C# program to convert Fahrenheit to Celsius
//Take input rom the user
using System;
namespace temperature
{
public class FtoC
{
    public static void Main(string[] args)
    {
        double celsius,fahrenheit; 
    //variable Declaration
        Console.WriteLine ("Enter temperature in Fahrenheit: ");
        //Ask input from user for fahrenheit
    fahrenheit=Convert.ToDouble(Console.ReadLine());
      //Reading the input
        celsius=((fahrenheit-32)*5/9);
    //Caculate Celsius
        Console.WriteLine ("The temperature in Celsius: "+celsius);
    //print celsius 
        Console.ReadKey();
    }
}
}

When the above code is executed, it produces the following result

Enter temperature in Fahrenheit:
50.0
The temperature in Celsius: 10

 

Convert Fahrenheit into  Celsius – Python

Python language

Program 5

# Python program to convert temperature in  Fahrenheit to Celsius 
fahrenheit=float(input("Enter temperature in Fahrenheit "))
#Ask input from the user

#Calculate celsius value
celsius=((fahrenheit-32)*5)/9

#Display result on the screen
print('%0.1f degrees Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))

When the above code is executed, it produces the following result

Enter temperature in Fahrenheit 70.0
70.0 degrees Fahrenheit is equal to 21.1 degree Celsius

 

Convert Fahrenheit into  Celsius – PHP

PHP language

Program 6

<?php
//PHP code to Convert to Fahrenheit into Celsius degrees
$fahrenheit=readline("Enter the Fahrenheit value: ");
//Takes input from user
$celsius=(($fahrenheit-32)*5)/9;
//Calculate celsius
echo("The temperature in Celsius is: ");
$celsius=round($celsius,3);
echo(($celsius));
//Print the result
?>

When the above code is executed, it produces the following result

Enter the Fahrenheit value: 190
The temperature in Celsius is: 87.778

 

Convert Fahrenheit into  Celsius – Javascript

Javascript language

Program 7

//program to Convert Fahrenheit to  Celsius
//Take input from the user
const fahrenheit=prompt("Enter a Fahrenheit value: ");
const celsius=(fahrenheit-32)*5/9;
//Calculate temperature of Celsius
console.log(`${fahrenheit} degrees Fahrenheit is equal to ${celsius} degrees Celsius.` );
//Display the result on the screen

When the above code is executed, it produces the following result

Enter a Fahrenheit value: 200.0
200.0 degrees Fahrenheit is equal to 93.33 degrees Celsius.

 

Similar post

Celsius into Fahrenheit in the C program

Fahrenheit into Celsius in C program

Celsius into Fahrenheit in C++ program

Fahrenheit into Celsius in C++ program

Celsius into Fahrenheit in the C# program

Fahrenheit into Celsius in C# program

Convert Celsius into Fahrenheit in Python

Convert Fahrenheit into Celsius in Python

Convert Celsius into Fahrenheit in PHP

Convert Fahrenheit into Celsius in PHP

Convert Celsius into Fahrenheit in JavaScript

Convert Fahrenheit into Celsius in JavaScript

 

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

Program to convert Celsius into Fahrenheit-Entered by user

Program to convert Celsius into Fahrenheit-Entered by user In this article, we will discuss the…

11 months ago

This website uses cookies.