Conversion Learn programming Java

Lesson:

First contact with Java


Exercise:

Conversion 9


Objetive:

Create a java program to convert from Celsius degrees to Kelvin and Fahrenheit: it will ask the user for the amount of Celsius degrees and using the following conversion tables:

Kelvin = Celsius + 273
Fahrenheit = Celsius x 18 / 10 + 32


Code:

import java.util.*;
public class Main
{
	static void main(String[] args)
	{
		System.out.print("Enter the amount of celsius: ");
		int celsius = Integer.parseInt(new Scanner(System.in).nextLine());
		System.out.printf("Kelvin = %1$s" + "\r\n", celsius + 273);
		System.out.printf("Fahrenheit = %1$s" + "\r\n", celsius * 18 / 10 + 32);
	}
}