Primitives Farenheit to Celsius to Kelvin calculator
this code serves to help people during science classes, when they need to convert temperatures from farenheit to SI units such as the Celsuis and
/*Primitives are data types which are the most basic and simple ons in Java. They are meant to
*contain simple forms of data, such as numbers and true/false. The main examples of Primitives
are booleans, char, int, float, and double.
*/
//This notebook will contain an example of Primitves being used
import java.util.Scanner;
public class TempConversions {
double celsius = 0;
double kelvin = 0;
String finalTempsGiven = "These are all the values of given temperature in Farenheit, Celsius, and Kelvin!"; //this string typed up shows the value that all value of temperature are given
public void convertTemp(double farenheit, boolean tempInFaren) {
if (tempInFaren == true) {
celsius = (((farenheit - 32) *5)/9) ; //temperature to convert from farenheit to celsius
System.out.println("The temperature in Farenheit is " + farenheit);
System.out.println("The temperature given in Farenheit, its value in degress Celsius is " + celsius + " degrees Celsius"); //gives temp in fareneheit
kelvin = celsius + 273.15; //temperature conversion from celsius to kelvin
System.out.println("The temperature given in Farenheit, its value in degrees Kevlin is " + kelvin + " degrees Kevlin"); //gives temp in kelvin
System.out.println(finalTempsGiven); //print string
}
else {
System.out.println("Error"); //prints error if no
}
//installation checks
}
public static void main (String[] args) {
boolean tempInFaren = true; //checks whether temperature
Scanner input = new Scanner(System.in);
System.out.println("Enter the temperature in Farenheit, because you live in the US!: "); //entering temperature in degrees farenheit
double farenheit = input.nextDouble(); //scanning the input
System.out.println("Is the temperature you entered in degrees Farenheit? Input true or false"); //checking whether the value inputed was in farenheit
tempInFaren = input.nextBoolean(); //scanning the input
TempConversions tempConverter = new TempConversions();
tempConverter.convertTemp(farenheit, tempInFaren);
}
}
TempConversions.main(null);