TUGAS KELOMPOK :
JANITHA TRIANA
DEVI
M. FAHMY ALDI
NICO TRI GANDA
2DB01
Program output_pascal;
uses crt;
label z;
label l;
var textfile:text;
FileName, TFile : String;
a:array[1..15] of string;
i,j:integer;
x,v:char;
temp: string;
procedure input;
Begin
clrscr;
Writeln('press Enter to input data '+
+' of the text file:');
readln(FileName);
writeln('.......DATA MAHASISWA......');
writeln('--------------------------');
writeln('KELAS NAMA NPM');
writeln('--------------------------');
{A .txt file will be assigned to a text variable}
Assign(textfile, 'G:\contoh.txt');
Reset(textfile); {'Reset(x)' - means open the file x}
Repeat
Readln(textfile,TFile);
Writeln(TFile);
Until Eof(textfile);
Close(textfile);
Readln;
End;
procedure sort;
begin
clrscr;
assign(textfile,'G:\contoh.TXT');
reset(textfile);
for i:=1 to 15 do readln(textfile,a[i]);
close(textfile);
for i:=1 to 14 do
for j:=i to 15 do
if a[j]<a[i] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;
assign(textfile,'G:\contoh.TXT');
rewrite(textfile);
for i:=1 to 15 do writeln(textfile,a[i]);
close(textfile);
end;
procedure output;
Begin
clrscr;
Writeln('Enter the file name '+
+'(with its full path) of the text file:');
readln(FileName);
writeln('......DATA MAHASISWA......');
writeln('--------------------------');
writeln('KELAS NAMA NPM');
writeln('--------------------------');
{A .txt file will be assigned to a text variable}
Assign(textfile, 'G:\contoh.txt');
Reset(textfile); {'Reset(x)' - means open the file x}
Repeat
Readln(textfile,TFile);
Writeln(TFile);
Until Eof(textfile);
Close(textfile);
Readln;
End;
begin
z: clrscr;
gotoxy(8,10); write('|******************|');
write(' Program Penyorting');
writeln('|******************|');writeln;
gotoxy(9,11);writeln('---------------------------------------------------------');
gotoxy(30,13);writeln('1.Masukkan Data');
gotoxy(30,14);writeln('2.Pensortiran Data');
gotoxy(30,15);writeln('3.Output');
gotoxy(30,16);writeln('4.Exit ');
gotoxy(1,20);writeln('Masukkan Pilihan (1,2,3,4) : ');readln(x);
case x of
'1' : input;
'2' : sort;
'3' : output;
'4' : goto l;
end;
if x = '2' then
begin
clrscr;
writeln('Selesai(tekan Enter)'); readln;
goto z;
end;
writeln('Apakah anda ingin kembali ke menu? : '); readln(v);
if (v = 'y') or (v = 'Y') then goto z;
l: end.
lanjutan :
lanjutan :
lanjutan :
lanjutan :
OUTPUT :
Tidak ada komentar:
Posting Komentar