-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestTemp.dpr
47 lines (37 loc) · 1.91 KB
/
TestTemp.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{**************************************************************************************}
{ }
{ Temperature Demo }
{ Class operators demonstration }
{ }
{ Copyright (c) 2004-2014 Chua Chee Wee }
{ Read article at http://chuacw.ath.cx/blogs/chuacw/archive/2004/04/29/464.aspx }
{ http://chuacw.ath.cx/blogs/chuacw/archive/tags/Delphi/default.aspx }
{**************************************************************************************}
program TestTemp;
{$APPTYPE CONSOLE}
uses Temperature, SysUtils;
var
F: Fahrenheit;
C: Celsius;
K: Kelvin;
begin
F := 98.6;
WriteLn('Fahrenheit to string: ', F.ToString);
C := F; // Convert Fahrenheit to Celsius
WriteLn(Format('Converting %s Fahrenheit to Celsius: %s', [F.ToString, C.ToString]));
C := 0.0; // Convert Celsius to Fahrenheit
WriteLn(Format('%s Celsius to Fahrenheit: %s', [C.ToString, Fahrenheit(Kelvin(C)).ToString]));
C := 100.0;
WriteLn(Format('%s Celsius to Fahrenheit: %s', [C.ToString, Fahrenheit(Kelvin(C)).ToString]));
F := Kelvin(C); // Convert Celsius to Kelvin to Fahrenheit
WriteLn(Format('%s Celsius to Kelvin to Fahrenheit: %s', [C.ToString, F.ToString]));
K := 0.0;
// Display Kelvin as Fahrenheit
WriteLn(Format('%s Kelvin as Fahrenheit: %s', [K.ToString, Fahrenheit(K).ToString]));
// Display Kelvin as Celsius
Writeln(Format('%s Kelvin as Celsius: %s', [K.ToString, Celsius(K).ToString]));
K := 373;
F := 98.6;
C := K - F;
WriteLn(Format('Subtracting %s Fahrenheit from %s Kelvin and display in Celsius: %s', [F.ToString, K.ToString, C.ToString]));
end.