2019-09-12 10:33:56 -07:00
|
|
|
import extensions;
|
2018-06-22 20:57:24 +00:00
|
|
|
|
2019-09-12 10:33:56 -07:00
|
|
|
convertKelvinToFahrenheit(x)
|
|
|
|
|
= x * 1.8r - 459.6r;
|
2018-06-22 20:57:24 +00:00
|
|
|
|
2019-09-12 10:33:56 -07:00
|
|
|
convertKelvinToRankine(x)
|
|
|
|
|
= x * 1.8r;
|
|
|
|
|
|
|
|
|
|
convertKelvinToCelsius(x)
|
|
|
|
|
= x - 273.15r;
|
|
|
|
|
|
|
|
|
|
public program()
|
|
|
|
|
{
|
|
|
|
|
console.print("Enter a Kelvin Temperature: ");
|
|
|
|
|
var inputVal := console.readLine();
|
|
|
|
|
real kelvinTemp := 0.0r;
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-02-17 23:21:07 -08:00
|
|
|
kelvinTemp := realConvertor.convert(inputVal)
|
2019-09-12 10:33:56 -07:00
|
|
|
}
|
|
|
|
|
catch(Exception e)
|
2018-06-22 20:57:24 +00:00
|
|
|
{
|
2019-09-12 10:33:56 -07:00
|
|
|
console.printLine("Invalid input value: ", inputVal);
|
2018-06-22 20:57:24 +00:00
|
|
|
|
2019-09-12 10:33:56 -07:00
|
|
|
AbortException.raise()
|
|
|
|
|
};
|
2018-06-22 20:57:24 +00:00
|
|
|
|
2019-09-12 10:33:56 -07:00
|
|
|
console.printLine("Kelvin: ", kelvinTemp);
|
|
|
|
|
console.printLine("Fahrenheit: ", convertKelvinToFahrenheit(kelvinTemp));
|
|
|
|
|
console.printLine("Rankine: ", convertKelvinToRankine(kelvinTemp));
|
|
|
|
|
console.printLine("Celsius: ", convertKelvinToCelsius(kelvinTemp));
|
|
|
|
|
console.readChar()
|
|
|
|
|
}
|