uses wincrt;
var
uts,uas :real;
tot :real;
ulang:char;
begin
ulang:='y';
while (ulang= 'y') or (ulang= 'Y') do
begin
clrscr;
write(' Masukan nilai UTS (Ujian Tengah Semester): ');
readln(uts);
write(' Masukan nilai UAS (Ujian Akhir Semester) : ');
readln(uas);
writeln;
tot:=0.6 * uas+0.4*uts;
writeln(' Nilai Akhir : ',tot:0:2);
if (tot>=80) then
writeln(' Nilai Indeks : A');
if (tot<80) and (tot>=70) then
writeln(' Nilai Indeks : B');
if (tot<70) and (tot>=50) then
writeln(' Nilai Indeks : C');
if (tot<50) and (tot>=30) then
writeln(' Nilia Indeks : D');
if (tot<30) then
writeln(' Nilai Indeks : E');
writeln;
write(' Apakah anda ingin mengulang? (y/n) ');
readln(ulang);
end;
end.
==========================
//Contoh Program Bahasa Paskal dengan menggunakan statment while
program RataWhile;
uses wincrt;
var
maxl,i : integer;
nilai, totnilai, rata : real;
begin
clrscr;
write ('Jumlah Data = ' );
readln(maxl);
writeln('');
i:=1;
while (i<=maxl) DO
begin
write('Nilai Data ke ',i ,' ? ');
readln(nilai);
totnilai := totnilai+nilai;
i:=i+1;
end;
writeln('');
rata:= totnilai/maxl;
writeln('Total Nilai = ',totnilai:0:2);
writeln('Jumlah Data = ',maxl);
writeln('Rata-rata Nilai = ',rata:0:2);
end.
0 comments :
Posting Komentar