Latihan 2.2
program Latihan0202;
uses wincrt;
function
upcase(nama,alamat:string):string;
var
nrp: string[8];
keterangan: string[2];
nd,pd,nl,pl,ket: string;
grade, pilih: char;
jumlah, nilai1, nilai2, nilai3: real;
i:integer;
begin
gotoxy(35,2);write(' PROGRAM LOGIN ');
gotoxy(35,3);write('~~~~~~~~~~~~~~~');
gotoxy(5,4);writeln('_______________');
gotoxy(5,5);writeln(' Pendaftaran ');
gotoxy(5,6);writeln('===============');
writeln;
write(' Masukkan Nama : ');read(ND);
readln;
write(' Masukkan Password : ');read(PD);
readln;
clrscr;
gotoxy(5,4);writeln('_________');
gotoxy(5,5);writeln(' LOGIN ');
gotoxy(5,6);writeln('---------');
writeln;
write(' Nama : ');read(NL);
readln;
write(' Password : ');read(PL);
readln;
clrscr;
if ND<>NL then
begin
write(' username atau password yang Anda inputkan salah ')
end
else
if PD<>PL then
begin
write(' username atau password yang Anda inputkan salah ')
end
else
begin
writeln(' 1. Memasukan Data Mahasiswa');
writeln(' 2. Keluar');
writeln;
write(' Pilihan Anda : '); readln(pilih);
writeln;
end;
case pilih of
'1': begin
write(' Masukkan Nama Anda : ' ); readln(nama);
write(' Masukkan NRP Anda : ' ); readln(nrp);
write(' Masukkan alamat anda : ' ); readln(alamat);
write(' Masukkan Nilai Tugas : ' ); readln(nilai1);
write(' Masukkan Nilai UTS : ' ); readln(nilai2);
write(' Masukkan Nilai UAS : ' ); readln(nilai3);
for i:=1 to length (nama) do
if (nama[i]>='a') and (nama[i]<='z') then
dec (nama[i],32);
upcase :=nama;
for i:=1 to length (alamat) do
if (alamat[i]>='a') and (alamat[i]<='z') then
dec (alamat[i],32);
upcase :=alamat;
{menentukan program studi}
if (copy(nrp, 3, 2)='11') then keterangan:= 'S1'
else
if (copy(nrp, 3, 2)='31') then keterangan:= 'D3';
{menentukan grade}
writeln;
jumlah:=((2*nilai3)+nilai1+nilai2)*0.25;
if jumlah>=80 then grade := 'A'
else
if jumlah>=70 then grade := 'B'
else
if jumlah>=60 then grade := 'C'
else
grade := 'D';
begin
if jumlah<=60 then ket:= 'TIDAK LULUS'
else
ket:= 'LULUS ';
end;
Writeln(' Data mahasiswa yang diinputkan ');
writeln;
writeln(' Nama : ',nama);
writeln(' NRP : ',nrp);
writeln(' Program Studi : ',keterangan);
writeln(' Alamat : ',alamat);
writeln(' Nilai Akhir : ',jumlah:2:2);
writeln(' Grade : ',grade);
writeln(' Keterangan : ',ket);
readln;
end;
'2': begin
writeln(' Anda mengakhiri program !');exit;
end;
else
begin
writeln(' Pilihan Anda Salah ');exit;
end;
end;
end;
begin
writeln(upcase('',''));
end.
uses wincrt;
function
upcase(nama,alamat:string):string;
var
nrp: string[8];
keterangan: string[2];
nd,pd,nl,pl,ket: string;
grade, pilih: char;
jumlah, nilai1, nilai2, nilai3: real;
i:integer;
begin
gotoxy(35,2);write(' PROGRAM LOGIN ');
gotoxy(35,3);write('~~~~~~~~~~~~~~~');
gotoxy(5,4);writeln('_______________');
gotoxy(5,5);writeln(' Pendaftaran ');
gotoxy(5,6);writeln('===============');
writeln;
write(' Masukkan Nama : ');read(ND);
readln;
write(' Masukkan Password : ');read(PD);
readln;
clrscr;
gotoxy(5,4);writeln('_________');
gotoxy(5,5);writeln(' LOGIN ');
gotoxy(5,6);writeln('---------');
writeln;
write(' Nama : ');read(NL);
readln;
write(' Password : ');read(PL);
readln;
clrscr;
if ND<>NL then
begin
write(' username atau password yang Anda inputkan salah ')
end
else
if PD<>PL then
begin
write(' username atau password yang Anda inputkan salah ')
end
else
begin
writeln(' 1. Memasukan Data Mahasiswa');
writeln(' 2. Keluar');
writeln;
write(' Pilihan Anda : '); readln(pilih);
writeln;
end;
case pilih of
'1': begin
write(' Masukkan Nama Anda : ' ); readln(nama);
write(' Masukkan NRP Anda : ' ); readln(nrp);
write(' Masukkan alamat anda : ' ); readln(alamat);
write(' Masukkan Nilai Tugas : ' ); readln(nilai1);
write(' Masukkan Nilai UTS : ' ); readln(nilai2);
write(' Masukkan Nilai UAS : ' ); readln(nilai3);
for i:=1 to length (nama) do
if (nama[i]>='a') and (nama[i]<='z') then
dec (nama[i],32);
upcase :=nama;
for i:=1 to length (alamat) do
if (alamat[i]>='a') and (alamat[i]<='z') then
dec (alamat[i],32);
upcase :=alamat;
{menentukan program studi}
if (copy(nrp, 3, 2)='11') then keterangan:= 'S1'
else
if (copy(nrp, 3, 2)='31') then keterangan:= 'D3';
{menentukan grade}
writeln;
jumlah:=((2*nilai3)+nilai1+nilai2)*0.25;
if jumlah>=80 then grade := 'A'
else
if jumlah>=70 then grade := 'B'
else
if jumlah>=60 then grade := 'C'
else
grade := 'D';
begin
if jumlah<=60 then ket:= 'TIDAK LULUS'
else
ket:= 'LULUS ';
end;
Writeln(' Data mahasiswa yang diinputkan ');
writeln;
writeln(' Nama : ',nama);
writeln(' NRP : ',nrp);
writeln(' Program Studi : ',keterangan);
writeln(' Alamat : ',alamat);
writeln(' Nilai Akhir : ',jumlah:2:2);
writeln(' Grade : ',grade);
writeln(' Keterangan : ',ket);
readln;
end;
'2': begin
writeln(' Anda mengakhiri program !');exit;
end;
else
begin
writeln(' Pilihan Anda Salah ');exit;
end;
end;
end;
begin
writeln(upcase('',''));
end.
screenshot output program
Semoga Bermanfaat.....