Sabtu, 26 November 2011

Flowchart Update Data File Sequential dan Programnya



Contoh program Sequential menggunakan COBOL :


IDENTIFICATION DIVISION.
PROGRAM-ID. SEQUEN1.
AUTHOR.
SECURITY. PROGRAM MEMASUKKAN DATA SEQUENSIAL.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PENJUALAN ASSIGN TO DISK.
ORGANIZATION IS SEQUENTIAL.
FILE STATUS IS STATUS-SALAH.
DATA DIVISION.
FILE SECTION.
FD PENJUALAN
LABEL RECORD IS STANDARD.
VALUE OF FILE-ID ID JUAL.DAT.
DATA RECORD IS RECORD-RELASI.
01 DATA-PENJUALAN.
02 NOMER-FAKTUR PIC X(12).
02 NAMA-LANGGANAN PIC X(25).
02 KODE-JUAL PIC A.
88 TUNAI VALUE IS ‘T’.
88 KREDIT VALUE IS ‘K’.
02 NILAI-JUAL PIC 9(6).
WORKING-STORAGE SECTION.
77 STATUS-SALAH PIC XX.
01 SUDAH-BENAR PIC X.
88 BENAR VALUE ‘Y’, ‘y’.
88 BELUM VALUE ‘T’, ‘t’.
01 MASUKKAN-LAGI-TIDAK PIC X.
88 LAGI VALUE ‘Y’,’y’.
88 TIDAK VALUE ‘T’,’t’.
SCREEN SECTION
01 HAPUS-LAYAR.
02 BLANK SCREEN.
01 LAYAR-DATA.
02 LINE 4 COLUMN 5 ‘NOMOR FAKTUR :’.
02 COLUMN PLUS 1 PIC X(22) TO NOMER-FAKTUR REQUIRED.
02 LINE 6 COLUMN 5 ‘NAMA LANGGANAN :’.
COLUMN PLUS 1 PIC X(25) TO NAMA-LANGGANAN.
02 LINE 8 COLUMN 5 ‘KODE TRANSAKSI :’.
02 COLUMN PLUS 1 PIC A TO KODE-JUAL.
02 LINE 10 COLUMN 5 ‘NILAI PENJUALAN :’.
02 COLUMN PLUS 1 PIC 9(6) TO NILAI-JUAL.
PROCEDURE DIVISION.
RYTIN-UTAMA SECTION.
BIKA-FILE.
OPEN OUTPUT PENJUALAN.
MULAI.
MOVE SPACE TO SUDAH-BENAR
PERFORM MASUKKAN-DATA UNTIL BENAR
PERFORM REKAM-DATA
PERFORM ADA-LAGI-TIDAK.
SELEKSI-MASUKKAN-LAGI-TIDAK.
IF LAGI
GO TO MULAI.
SELESAI.
CLOSE PENUALAN
STOP RUN.
RUTIN-BAGIAN SECTION.
MASUKKAN-DATA.
DISPLAY HAPUS-LAYAR
DISPLAY LAYAR-DATA
ACCEPT LAYA-DATA.
DISPLAY (18,5) ‘SUDAH BENAR (Y/T)?’.
ACCEPT ( , ) SUDAH BENAR.
REKAM-DATA.
MOVE ‘ ‘ TO STATUS-SALAH
WRITE DATA-PENJUALAN
PERFORM SELEKSI REKAMAN.
ADA-LAGI-TIDAK.
DISPLAY (20,5) ‘ADA LAGI DATA LAINNYA (Y/T)?’
ACCEPT ( , ) MASUKKAN-LAGI-TIDAK.
SELEKSI-REKAMAN.
IF STATUS-SALAH = ‘34’
DISPLAY (18,5) ‘TIDAK TEREKAM, DISK PENUH’.
IF STATUS-SALAH = ‘91’
DISPLAY (18,6) ‘STURKTUR FILE RUSAK’.

Program File Mahasiswa dengan Pascal

Ini adalah program File Mahasiswa dengan menggunakan bahasa pemrograman Pascal.
coding program sebagai berikut :


uses crt;
const
garis ='======================================================';

type Mahasiswa = record
nama: string[25];
npm: string[8];
kelas: string[5];
end;
type
tipelarik= string[25];
larikurut=array[1..100] of tipelarik;

var
file_mhs : file of Mahasiswa;
filemhs : Mahasiswa;
i,j, jumlah_data : integer;
lagi : char;
temp: string[5];
pil : integer;
gabung : larikurut;
gabung1 : larikurut;



procedure input;
begin
assign (file_mhs, 'Mhs.txt') ;
rewrite (file_mhs);
i := 0;
repeat
inc(i);
clrscr;
writeln('Mengisi data pada file "Mhs.txt"....');
writeln('------------------------------------');
writeln('Mengisi Data ke-', i);
writeln;
with filemhs do
begin
write('Nama Mahasiswa : ');Readln(nama);
write('NPM Mahasiswa : '); readln(npm);
write('Kelas : '); readln(kelas);
end;
write(file_mhs,filemhs);
writeln;
write('Akan Mengisi Lagi [Y/T] : '); readln(lagi);
until Not (lagi In ['Y','y']);
close(file_mhs);
end;


procedure sortir(x:larikurut; bawah,atas :word);
var i,j :word;
sementara :tipelarik;
begin
while atas>bawah do
begin
i:=bawah;
j:=atas;
sementara:=x[bawah];
while i begin
WHILE x[j]>sementara Do
J:=J-1;
x[i]:=x[j];
while(i i:=i+1;
x[j]:=x[i];
end;
x[i]:=sementara;
sortir(x,bawah,i-1);
bawah:=i+1;
end;
end;



procedure cetak;
begin
assign(file_mhs,'Mhs.txt');
reset(file_mhs);
clrscr;
jumlah_data := FileSize (file_mhs);
writeln(' ':20,'Daftar Absensi Mahasiswa Gunadarma');
writeln(' ':20,'==================================');
writeln; writeln (garis);
writeln('| no | Nama Mahasiswa | NPM | Kelas |');
writeln (garis);
for i:= 1 to jumlah_data do
begin
read(file_mhs,filemhs);
gotoxy (1,wherey); write('| ',i:2,' |');
with filemhs Do
begin
gotoxy (8,wherey); writeln ( filemhs.nama);
gotoxy (35,wherey); write('| ', filemhs.npm);
gotoxy(46,wherey); write('| ',filemhs.kelas,' |');
end;
writeln;
end;
writeln(garis);
readln;
close(file_mhs);
end;

procedure tampilsortir;
label empat;
var
gabung,gabung1,name,npms,class:larikurut;
i,J:integer;temp:STRING[5];
begin
clrscr;
assign(file_mhs,'Mhs.txt');
reset(file_mhs);
for i := 1 to filesize(file_mhs) do
begin
seek(file_mhs, i-1);
read (file_mhs,filemhs);
name[i] := filemhs.nama;
class[i] := filemhs.kelas;
npms[i] := filemhs.npm;
gabung[i] := concat(name[i],npms[i],class[i]);
gabung1[i] := concat(class[i], name[i], npms[i]);
end;


j := 2;
sortir(gabung1,1,filesize(file_mhs));
write('kelas : '); readln (temp);
if length(temp) <> 5 then
begin
clrscr;
gotoxy(28,100);
writeln('Kelas tidak ditemukan');
clrscr;
writeln('Kelas :', temp);
writeln('daftar mahasiswa');
goto empat;
end;


clrscr;
empat:
writeln (garis);
writeln ('| no | Nama Mahasiswa | NPM | Kelas |');
writeln (garis);
for i:= 1 to filesize(file_mhs) do
begin
if (name[i]<> ' ') then begin

writeln('| ', i:2,'| ', copy(gabung[i],18,8),' ', copy(gabung[i],0,5),' ', copy(gabung[i],6,12)); end;
end;
j:=I+10;
end;

procedure tambahdata;
begin
assign(file_mhs,'Mhs.txt');
reset(file_mhs);
if IOresult <> 0 then rewrite(file_mhs);
seek(file_mhs,filesize(file_mhs));
lagi := 'Y';
while upcase(lagi)='Y' do
begin
clrscr;
with filemhs do
begin
gotoxy(5,5);write('-----------------------------------------------------');
gotoxy(5,6);write('|nama mahasiswa : |');
gotoxy(5,7);write('|npm mahasiswa : |');
gotoxy(5,8);write('|kelas mahasiswa : |');
gotoxy(5,9);write('-----------------------------------------------------');
gotoxy(27,6);readln(kelas);
gotoxy(27,7);readln(npm);
gotoxy(27,8);readln(nama);
end;
write(file_mhs, filemhs);
gotoxy(5,15);write('anda ingin memasukkan data lagi(Y/T)?');readln(lagi);
end;
close(file_mhs);
end;

begin
repeat
clrscr;
writeln (' Menu ');
writeln ('1. Input data');
writeln ('2. Sort data');
writeln ('3. output data');
writeln ('4. Update data');
writeln ('5. keluar');
write ('Masukkan pilihan : '); readln(pil);
case pil of
1 : input;
2 : tampilsortir;
3 : cetak;
4 : tambahdata
end;
until pil = 5;
end.


output :






Pilih 1




Memasukkan data ke-1




Memasukkan data ke-2



Memasukkan data ke-3



Pilih 2



Sorting Berdasarkan Kelas



Pilih 3



Output data



Pilih 4



Update data


Hasil output setelah data di-update


Untuk keluar dari program Pilih 5.

Kelompok :
  • Anandya Revannie Putri (30110637)
  • Fanny Nurrizky (32110598)
  • Kartika Ratu T (33110849)
  • Martika Alfiani (34110241)
  • Ni Nyoman Astri Widyantari (34110951)