Description

This basic java example source code reads the temperature in Kelvin from console and calculate the equivalent in Degree Celsius.

Degree Kelvin to Degree Celsius 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 Kelvin from console input
 * Java Program to convert Kelvin to Degree Celsius
 */

public class ConvertKelvinCelsius {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// Declare the reader from console
		BufferedReader br;
		// Get the console input for the temperature in Kelvin
		System.out.println("Temperature in Kelvin:");		
		br = new BufferedReader(new InputStreamReader(System.in));
		// assign to float variable the temperature in Kelvin
		float kelvin = Float.parseFloat(br.readLine());
		// Kelvin to Degree Celsius Conversion
		float celsius = kelvin - 273.15F;
		System.out.println("Celsius: "+ celsius);

	}

}

Sample Output

Temperature in Kelvin:
103.25
Celsius: -169.9

Suggested Reading List