Description

This basic java example source code reads the temperature in degrees centigrade from console and calculate the equivalent in degrees fahrenheit.

Degree Celsius to Fahrenheit Conversion Source Code

package com.javatutorialhq.java.examples;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * This basic java example source code
 * reads temperature in degrees centigrade from console input
 * Java Program to convert Degree Celsius to Fahrenheit
 */

public class ConvertDegreesFahrenheit {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// Declare the reader from console
		BufferedReader br;
		// Get the console input for the temperature in degree celsius
		System.out.println("Temperature in Degree Celsius:");		
		br = new BufferedReader(new InputStreamReader(System.in));
		// assign to double variable the degree celsius
		double degrees = Double.parseDouble(br.readLine());
		// Degree Celsius to Degrees Fahrenheit Conversion
		double fahrenheit = (9*degrees/5) + 32;
		System.out.println("Fahrenheit: "+ fahrenheit);

	}

}

Sample Output

Temperature in Degree Celsius:
12
Fahrenheit: 53.6

Suggested Reading List