Kali ini saya ingin memposting tugas PAA bu Elly. Tugasnya adalah membuat penjumlahan bilangan, dimana setiap pencetakan 25 bilangan maka harus beganti halaman kemudian di cetak jumlahnya. Berikut program asal-asalan yang Saya buat
program revisi;
uses crt;
var n, no, i, total, a, hal, data, batas : integer;
x: array[1..100] of integer;
begin
clrscr;
no := 1;
total := 0;
hal := 0;
data := 25;
batas := 0;
write('masukan Jumlah bilangan yang akan di input : ');read(n);
writeln(' ');
writeln('==============================');
writeln(' NO| Data input |');
writeln('=============================');
for i:= 1 to n do
begin
write(no:2,' | input bilangan : ');read(x[i]);
no := no + 1;
end;
clrscr;
writeln('============================================');
writeln(' No| perhitungan | Hasil |');
writeln('============================================');
for i := 1 to n-1 do
begin
a := x[i];
total := total + a;
if i = 1 then
begin
writeln(i:2,' | ',x[i]:2, ' + ', x[i+1],' | ',total + x[i+1]:2,' |':2);
end
else
writeln(i:2,' | ',total:2, ' + ',x[i+1],' | ', total + x[i+1]:2,' |':2);
hal := hal + 1;
if hal = data then
begin
batas := batas + 1;
writeln(' ');
writeln('==============halaman ',batas ,' ====================');
writeln('| jumlah : ',total + x[i+1],' |');
writeln('============================================');
writeln(' ');
data := data + 25;
end;
end;
writeln('============================================');
writeln('Total Semua : ',total + x[i+1]);
readln;
readln;
end.
Post a Comment