Primitives - Temperature Converter
import java.util.Scanner;
public class CelciustoKelvin {
public static void main (String[] args) {
Scanner input;
//use of wrapper class
String aString = "This is our program to convert Celcius to Kelvin. We are using it for our AP Chemistry class.";
System.out.println(aString);
//we used the string to greet the user
input = new Scanner(System.in);
System.out.println("Enter your name as a string: ");
String name = input.nextLine();
System.out.println("Hello " + name );
input.close();
//the integer is used to get the age of the user
input = new Scanner(System.in);
System.out.println("Enter your age as an integer: ");
String age = input.nextLine();
System.out.println("You are " + age + " years old." );
input.close();
//boolean is used to get a true or false answer about whether the user is in AP Chem
input = new Scanner(System.in);
System.out.println("Are you in AP Chemistry? Enter your answer as a Boolean: ");
String chem = input.nextLine();
System.out.println("Your answer: " + chem);
input.close();
//double is used to get a number from the user and convert it using arithmetic expression
input = new Scanner(System.in);
System.out.println("Enter a degree in Celsius as a double: ");
double celsius = input.nextDouble();
double kelvin = (celsius + 273.0);
System.out.println( celsius + " degree Celsius is equal to " + kelvin + " in Kelvin");
input.close();
}
}
CelciustoKelvin.main(null);