Jumat, 19 November 2010

Program Konversi Celcius dalam Bahasa Pascal

Program konversi ;

var c, reamur, fahrenheit, kelvin :real ;
a : byte ;
b : char ;

begin
repeat

            writeln ('program konversi celcius');
            writeln ('--------------------------');
            writeln ('1. celcius ke reamu');
            writeln ('2. celcius ke fahrenheit');
            writeln ('3. celcius ke kelvin');
            writeln ('0. selesai');
            write ('pilih nomor konversi : '); readln (a);

if a =1 then
begin
            write ('derajat celcius ='); readln (c);
            reamur := 0.8*c ;
            writeln  ('derajat reamur =', reamur) ;
end ;
          
if a =2 then
begin
            write ('derajat celcius ='); readln (c);
            fahrenheit := c * 1.8 + 32 ;
            writeln  ('derajat fahrenheit =', fahrenheit) ;
end ;

if a =3 then
begin
            write ('derajat celcius ='); readln (c);
            kelvin := c + 273.15 ;
            writeln  ('derajat kelvin =', kelvin) ;
end ;

if a =0 then
begin
            writeln  ('program selesai');
end ;

writeln  ;
write ('mau coba lagi [Y/T] : '); readln (b);
until b = 'T';
readln ;
readln ;
end .

0 komentar:

Posting Komentar