libreoffice code snipper with captrion code example
Example: PASTE CODE IN LIBREoffice WRITER
package qmul.ecs505.lab8;
/**
* Fahrenheit F
* Celsius C
* Kelvin K
*/
public class TemperatureConverter {
public static double FAHRENHEIT_MAX = 9900000000032d;
public static double FAHRENHEIT_MIN = -459.67d;
public static double CELSIUS_MAX = 5500000000000d;
public static double CELSIUS_MIN = -273.15d;
public static double KELVIN_MAX = 5500000000273.15d;
public static double KELVIN_MIN = 0d;
//Fahrenheit to Celsius
double F2C(double tempF) throws IllegalArgumentException {
if (tempF >= FAHRENHEIT_MIN && tempF <= FAHRENHEIT_MAX) {
return ((tempF - 32) / 1.8);
}
throw new IllegalArgumentException();
}
double F2K(double tempF) throws IllegalArgumentException {
if (tempF >= FAHRENHEIT_MIN && tempF <= FAHRENHEIT_MAX) {
return ((tempF + 459.67) / 1.8);
}
throw new IllegalArgumentException();
}
double C2F(double tempC) throws IllegalArgumentException {
if (tempC >= CELSIUS_MIN && tempC <= CELSIUS_MAX) {
return (tempC * 1.8) + 32;
}
throw new IllegalArgumentException();
}
double C2K(double tempC) throws IllegalArgumentException {
if (tempC >= CELSIUS_MIN && tempC <= CELSIUS_MAX) {
return (tempC + 273.15);
}
throw new IllegalArgumentException();
}
double K2F(double tempK) throws IllegalArgumentException {
if (tempK >= KELVIN_MIN && tempK <= KELVIN_MAX) {
return ((tempK * 1.8) - 459.67);
}
throw new IllegalArgumentException();
}
double K2C(double tempK) throws IllegalArgumentException {
if (tempK >= KELVIN_MIN && tempK <= KELVIN_MAX) {
return (tempK - 273.15);
}
throw new IllegalArgumentException();
}
}