Infolinks

Breaking

Adsense

Thursday, January 28, 2016

JAVA CELSIUS TO FAHRENHEIT: Celsius to Fahrenheit Java Converter Code


Hi there! The following tutorial will introduce you to one of the most common problems encountered in programming subjects. Later on, I will provide set of activities and quizzes for you to practice on to improve your programming skills.

A temperature converter made in java is just one of the exercises given by most programming instructors. Some other exercises are the following:

5.     Fibonacci Series

and many more. These are just some of the activities that I posted here in my blog. You can visit the links if you want.

Hi there! This article will create a simple temperature converter from Fahrenheit to Celsius and vice versa. We will be using the following formula to solve for value in Fahrenheit to Celsius and Celsius to Fahrenheit using java language.

Visit my post about Celsius to Fahrenheit in PHP here.

Formula Celsius to Fahrenheit


C  x  9/5 + 32 = F
(F  -  32)  x  5/9 = C

First, we will convert Celsius to Fahrenheit. Let's try to convert 32 degrees Celsius to degrees Fahrenheit.

Java CodeCelsius to Fahrenheit

import java.util.Scanner; 
public class TempConverter{

public static void main(String[] args) {

// convert celsius to fahrenheit
double celsius = 32;
double f=celsius*9/5+32;
System.out.printf("%.2f Celsius is equivalent to %.2f in Fahrenheit\n",celsius,f);
        double fahrenheit = 89.6; 
double c=(fahrenheit-32)*5/9;
System.out.printf("%.2f Fahrenheit is equivalent to %.2f in Celsius",fahrenheit,c);
}
}

Output Celsius to Fahrenheit






Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

JAVA CELSIUS TO FAHRENHEIT: Celsius to Fahrenheit Java Converter Code

No comments:

Post a Comment

Adbox