program rata_rata;
uses wincrt;
var
a, mahasiswa : integer;
nilai, total, tinggi, rendah, rata : real;
nama:string;
begin
total := 0;
write ('jumlah mahasiswa : '); readln (mahasiswa);
writeln;
for a := 1 to mahasiswa do
begin
write ('nama mahasiswa ke ',a,' ');readln (nama);
write ('nilai ',nama,' : '); readln (nilai);
total := total + nilai;
if a = 1 then
begin
tinggi := nilai;
rendah := nilai;
end
else begin
if nilai > tinggi then tinggi := nilai
else begin
if nilai < rendah then rendah := nilai
else begin
end;
end;
end;
end;
rata := total / mahasiswa;
writeln;
writeln ('nilai terendah : ',rendah :1:2);
writeln ('nilai tertinggi : ',tinggi :1:2);
writeln ('rata-rata nilai mahasiswa : ',rata :1:2);
readln;
donewincrt
end.
program rata-rata
Categories:
program bahasa pascal
0 comments:
Post a Comment