daily pastebin goal
38%
SHARE
TWEET

SOAL NO 3 UTS 15

a guest Dec 7th, 2017 184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program TemperaturKota;
  2. const NMax = 31;
  3. type
  4.     TInt = Array [1..NMax] of integer;
  5.     TReal = Array [1..NMax] of real;
  6. var
  7.     TempF : TInt;
  8.     NEff1 : integer;
  9.     TempK : TReal;
  10.     NEff2 : integer;
  11.     fin : textfile; //fileofinteger juga sabi
  12.     i : integer;
  13.     x : integer;
  14.     rata : real;
  15.    
  16.  
  17. procedure HitungRerata (Tab : TInt; Neff : integer; var rerata : real);
  18. var
  19.     sum : integer;
  20. begin
  21.     sum := 0;
  22.     for i := 1 to Neff do begin
  23.         sum := sum + Tab[i];
  24.     end;
  25.     rerata := rerata * (sum / Neff );
  26.     writeln (rerata:0:1);
  27. end;
  28.  
  29. function KonversiFKeK (TF : integer) : real;
  30. begin
  31.     KonversiFkeK := ((TF + 459.67)*5)/9;
  32. end;   
  33.  
  34. begin
  35. {ALGO UTAMA}
  36.     assign ( fin, 'temperatur.dat');
  37.     reset (fin);
  38.         i := 1;
  39.         while not (EOF (fin)) do begin
  40.             read (fin , x);
  41.             TempF [i] := x;
  42.             i := i + 1;
  43.         end;
  44.         Neff1 := i -1;
  45.     close (fin);
  46.     writeln ('Temperatur rata-rata dalam derajat Fahrenheit = ');
  47.     rata := 1.00;
  48.     HitungRerata (TempF , Neff1 , rata );
  49.      
  50.     Neff2 := Neff1;
  51.    
  52.     for i := 1 to Neff2 do begin
  53.         TempK[i] := KonversiFkeK (TempF[i]);
  54.     end;
  55.    
  56.     writeln ('Temperatur harian dalam derajat Kelvin = ');
  57.     for i := 1 to Neff2 do begin
  58.         writeln (TempK[i] :0:2);
  59.     end;
  60. end.
RAW Paste Data
Top