Kamis, 21 Juli 2011

Akhir Praktek Pemrograman Semester 2

Postingan kedua di hari ini..

Saya cuma mau sharing program untuk Tugas Akhir praktek pemrograman saya.  Dalam versi bahasa C dan Pascal.. 
Sebenarnya programnya cukup sederhana.. Cuma agak panjang..

Programnya mungkin bisa dikasih nama "Photocopy Self Service"... 


Here it is..


Source Code Pascal:


uses crt;
var
    pil,x,i:integer;yt:integer;
    label a;
procedure header;
begin
clrscr;
gotoxy(20,1);write('+*************************************+');
gotoxy(20,2);write('*-------------------------------------*');
gotoxy(20,3);write('*  WELCOME TO RiJef Photocopy Centre  *');
gotoxy(20,4);write('*-------------------------------------*');
gotoxy(20,5);write('+*************************************+');
gotoxy(24,7);write('Pembayaran Fotokopi Self-Service');
end;

procedure kertas_f4;
var total,total1,sisa:real;
    label m,e;
begin
clrscr;
header;
gotoxy(12,10);write('+****************************************************+');
gotoxy(12,11);write('*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *');
gotoxy(12,12);write('+****************************************************+');
gotoxy(12,13);write('*   Rp. 150,-');
gotoxy(1,20);write('Masukkan banyaknya lembar yang telah di-fotokopi :');readln(x);
gotoxy(32,13);write('*       ',x);
m:
gotoxy(1,21);write('Bolak-balik atau tidak (1/2) ? ');clreol;readln(yt);
if (yt=1) then
begin
total:=150*2*x;
end
else
if (yt=2) then
begin
total:=150*x;
end
else
goto m;
gotoxy(50,13);write('*   Rp.',total:2:0,',-');
gotoxy(65,13);write('*');
gotoxy(12,14);write('+****************************************************+');
e:
gotoxy(12,15);write('* Uang Yang Anda Bayar                *              *');
gotoxy(12,16);write('+****************************************************+');
gotoxy(54,15);write('Rp.');readln(total1);
sisa:=total1-total;
if (sisa<0) then goto e else
begin
gotoxy(12,17);write('* Silakan Ambil Kembalian Sendiri     *              *');
gotoxy(54,17);write('Rp.',sisa:1:0,',-');
gotoxy(12,18);write('+****************************************************+');
end;
end;

procedure kertas_A5;
var total,total1,sisa:real;
    label z,d;
begin
clrscr;
header;
gotoxy(12,10);write('+****************************************************+');
gotoxy(12,11);write('*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *');
gotoxy(12,12);write('+****************************************************+');
gotoxy(12,13);write('*   Rp. 100,-');
gotoxy(1,20);write('Masukkan banyaknya lembar yang telah di-fotokopi :');readln(x);
gotoxy(32,13);write('*       ',x);
z:
gotoxy(1,21);write('Bolak-balik atau tidak (1/2) ? ');clreol;readln(yt);
if yt=1 then
begin
total:=100*2*x;
end
else
if (yt=2) then
begin
total:=x*100;
end
else
goto z;
gotoxy(50,13);write('*   Rp.',total:2:0,',-');
gotoxy(65,13);write('*');
gotoxy(12,14);write('+****************************************************+');
d:
gotoxy(12,15);write('* Uang Yang Anda Bayar                *              *');
gotoxy(12,16);write('+****************************************************+');
gotoxy(54,15);write('Rp.');readln(total1);
sisa:=total1-total;
if (sisa<0) then goto d else
begin
gotoxy(12,17);write('* Silakan Ambil Kembalian Sendiri     *              *');
gotoxy(54,17);write('Rp.',sisa:2:0,',-');
gotoxy(12,18);write('+****************************************************+');
end;
end;

procedure kertas_A4;
var total,total1,sisa:real;
    label o,c;
begin
clrscr;
header;
gotoxy(12,10);write('+****************************************************+');
gotoxy(12,11);write('*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *');
gotoxy(12,12);write('+****************************************************+');
gotoxy(12,13);write('*   Rp. 150,-');
gotoxy(1,20);write('Masukkan banyaknya lembar yang telah di-fotokopi :');readln(x);
gotoxy(32,13);write('*       ',x);
o:
gotoxy(1,21);write('Bolak-balik atau tidak (1/2) ? ');clreol;readln(yt);
if yt=1 then
begin
total:=150*2*x;
end
else
if (yt=2) then
begin
total:=150*x;
end
else
goto o;
gotoxy(50,13);write('*   Rp.',total:2:0,',-');
gotoxy(12,14);write('+****************************************************+');
gotoxy(65,13);write('*');
c:
gotoxy(12,15);write('* Uang Yang Anda Bayar                *              *');
gotoxy(12,16);write('+****************************************************+');
gotoxy(54,15);write('Rp.');readln(total1);
sisa:=total1-total;
if (sisa<0) then goto c else
begin
gotoxy(12,17);write('* Silakan Ambil Kembalian Sendiri     *              *');
gotoxy(54,17);write('Rp.',sisa:2:0,',-');
gotoxy(12,18);write('+****************************************************+');
end;
end;

procedure kertas_A3;
var total,total1,sisa:real;
    label p,b;
begin
clrscr;
header;
gotoxy(12,10);write('+****************************************************+');
gotoxy(12,11);write('*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *');
gotoxy(12,12);write('+****************************************************+');
gotoxy(12,13);write('*   Rp. 350,-');
gotoxy(1,20);write('Masukkan banyaknya lembar yang telah di-fotokopi :');readln(x);
gotoxy(32,13);write('*        ',x);
p:
gotoxy(1,21);write('Bolak-balik atau tidak (1/2) ? ');clreol;readln(yt);
if yt=1 then
begin
total:=350*2*x;
end
else
if (yt=2) then
begin
total:=x*350;
end
else
goto p;
gotoxy(50,13);write('*   Rp.',total:1:0);
gotoxy(12,14);write('+****************************************************+');
gotoxy(65,13);write('*');
b:
gotoxy(12,15);write('* Uang Yang Anda Bayar                *              *');
gotoxy(12,16);write('+****************************************************+');
gotoxy(54,15);write('Rp.');readln(total1);
sisa:=total1-total;
if (sisa<0) then goto b else
begin
gotoxy(12,17);write('* Silakan Ambil Kembalian Sendiri     *              *');
gotoxy(54,17);write('Rp.',sisa:2:0,',-');
gotoxy(12,18);write('+****************************************************+');
end;
end;


begin
a:
clrscr;
header;
gotoxy(30,9);write('1. Kertas F4');
gotoxy(30,10);write('2. Kertas A5');
gotoxy(30,11);write('3. Kertas A4');
gotoxy(30,12);write('4. Kertas A3');
gotoxy(30,13);write('5. Keluar');
gotoxy(20,16);write('Masukkan kertas pilihan anda : ');readln(pil);
case pil of
1: begin
   kertas_f4;
   readln;
   goto a;
   end;
2: begin
   kertas_A5;
   readln;
   goto a;
   end;
3: begin
   kertas_A4;
   readln;
   goto a;
   end;
4: begin
   kertas_A3;
   readln;
   goto a;
   end;
5: begin
   clrscr;
   textcolor(16);gotoxy(16,12);writeln('Created By Afrinaldi And Jefri Rajif PTI 2010');
   end;
6..100: begin
        write('Inputan salah, Menu hanya sampai 5');
        readln;
        goto a;
        end;
end;
readln;
end.



Source Code C:


#include <stdio.h>
#include <conio.h>


void header(), kertas_f4(), kertas_A5(),kertas_A4(), kertas_A3();


void header()
{
clrscr();
gotoxy(20,1);printf("+*************************************+");
gotoxy(20,2);printf("*-------------------------------------*");
gotoxy(20,3);printf("*  WELCOME TO RiJef Photocopy Centre  *");
gotoxy(20,4);printf("*-------------------------------------*");
gotoxy(20,5);printf("+*************************************+");
gotoxy(24,7);printf("Pembayaran Fotokopi Self-Service");
}

void kertas_f4()
{
char yt;
int x;
clrscr();
float total,total1,sisa;
header();
gotoxy(12,10); printf("+****************************************************+");
gotoxy(12,11);printf("*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *");
gotoxy(12,12); printf("+****************************************************+");
gotoxy(12,13);printf("*   Rp. 150,-");
gotoxy(1,20);printf("Masukkan banyaknya lembar yang telah di-fotokopi :");scanf("%d",&x);
gotoxy(32,13);printf("*       %d",x);
m:
gotoxy(1,21);printf("Bolak-balik atau tidak Y/N ? ");clreol();
scanf("%s",&yt);
if(yt=='y' || yt=='Y')
{
total=150*2*x;
}
else if(yt=='n' || yt=='N')
{
total=x*150;
}
else goto m;
gotoxy(50,13);printf("*   Rp.%2.f,-",total);
gotoxy(65,13);printf("*");
gotoxy(12,14);printf("+****************************************************+");
e:
gotoxy(12,15);printf("* Uang Yang Anda Bayar                *              *");
gotoxy(12,16);printf("+****************************************************+");
gotoxy(54,15);printf("Rp.");scanf("%f",&total1);gotoxy(54,15);
sisa=total1-total;
if (sisa<0) goto e; else
{
gotoxy(12,17);printf("* Silakan Ambil Kembalian Sendiri     *              *");
gotoxy(54,17);printf("Rp.%2.0f,-",sisa);
gotoxy(12,18);printf("+****************************************************+");
}
}

void kertas_A5()
{
char yt;
int x;
float total,total1,sisa;
clrscr();
header();
gotoxy(12,10); printf("+****************************************************+");
gotoxy(12,11);printf("*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *");
gotoxy(12,12); printf("+****************************************************+");
gotoxy(12,13);printf("*   Rp. 100,-");
gotoxy(1,20);printf("Masukkan banyaknya lembar yang telah di-fotokopi :");scanf("%d",&x);
gotoxy(32,13);printf("*       %d",x);
n:
gotoxy(1,21);printf("Bolak-balik atau tidak Y/N ? ");clreol();
scanf("%s",&yt);
if(yt=='y' || yt=='Y')
{
total=100*2*x;
}
else if(yt=='n' || yt=='N')
{
total=x*100;
}else goto n;
gotoxy(50,13);printf("*   Rp.%2.f,-",total);
gotoxy(65,13);printf("*");
gotoxy(12,14);printf("+****************************************************+");
d:
gotoxy(12,15);printf("* Uang Yang Anda Bayar                *              *");
gotoxy(12,16);printf("+****************************************************+");
gotoxy(54,15);printf("Rp.");scanf("%f",&total1);gotoxy(54,15);
sisa=total1-total;
if (sisa<0) goto d; else
{
gotoxy(12,17);printf("* Silakan Ambil Kembalian Sendiri     *              *");
gotoxy(54,17);printf("Rp.%2.0f,-",sisa);
gotoxy(12,18);printf("+****************************************************+");
}
}

void kertas_A4()
{
char yt;
int x;
float total,total1,sisa;
clrscr();
header();
gotoxy(12,10); printf("+****************************************************+");
gotoxy(12,11);printf("*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *");
gotoxy(12,12); printf("+****************************************************+");
gotoxy(12,13);printf("*   Rp. 150,-");
gotoxy(1,20);printf("Masukkan banyaknya lembar yang telah di-fotokopi :");scanf("%d",&x);
gotoxy(32,13);printf("*       %d",x);
o:
gotoxy(1,21);printf("Bolak-balik atau tidak Y/N ? ");clreol();
scanf("%s",&yt);
if(yt=='y' || yt=='Y')
{
total=150*2*x;
}
else if(yt=='n' || yt=='N')
{
total=x*150;
}
else goto o;
gotoxy(50,13);printf("*   Rp.%2.f,-",total);
gotoxy(65,13);printf("*");
gotoxy(12,14);printf("+****************************************************+");
c:
gotoxy(12,15);printf("* Uang Yang Anda Bayar                *              *");
gotoxy(12,16);printf("+****************************************************+");
gotoxy(54,15);printf("Rp.");scanf("%f",&total1);gotoxy(54,15);
sisa=total1-total;
if (sisa<0) goto c; else
{
gotoxy(12,17);printf("* Silakan Ambil Kembalian Sendiri     *              *");
gotoxy(54,17);printf("Rp.%2.0f,-",sisa);
gotoxy(12,18);printf("+****************************************************+");
}
}

void kertas_A3()
{
char yt;
int x;
float total,total1,sisa;
clrscr();
header();
gotoxy(12,10); printf("+****************************************************+");
gotoxy(12,11);printf("*   Harga Per/Sisi  *  Jumlah Lembar  *  Total Harga *");
gotoxy(12,12); printf("+****************************************************+");
gotoxy(12,13);printf("*   Rp. 350,-");
gotoxy(1,20);printf("Masukkan banyaknya lembar yang telah di-fotokopi :");scanf("%d",&x);
gotoxy(32,13);printf("*       %d",x);
p:
gotoxy(1,21);printf("Bolak-balik atau tidak Y/N ? ");clreol();
scanf("%s",&yt);
if(yt=='y' || yt=='Y')
{
total=350*2*x;
}
else if(yt=='n' || yt=='N')
{
total=x*350;
}
else goto p;
gotoxy(50,13);printf("*   Rp.%2.f,-",total);
gotoxy(65,13);printf("*");
gotoxy(12,14);printf("+****************************************************+");
b:
gotoxy(12,15);printf("* Uang Yang Anda Bayar                *              *");
gotoxy(12,16);printf("+****************************************************+");
gotoxy(54,15);printf("Rp.");scanf("%f",&total1);gotoxy(54,15);
sisa=total1-total;
if (sisa<0) goto b; else
{
gotoxy(12,17);printf("* Silakan Ambil Kembalian Sendiri     *              *");
gotoxy(54,17);printf("Rp.%2.0f,-",sisa);
gotoxy(12,18);printf("+****************************************************+");
}
}

int main()
{
int pil;
x:
clrscr();
header();
gotoxy(30,9);printf("1. Kertas F4");
gotoxy(30,10);printf("2. Kertas A5");
gotoxy(30,11);printf("3. Kertas A4");
gotoxy(30,12);printf("4. Kertas A3");
gotoxy(30,13);printf("5. Keluar");
gotoxy(30,16);printf("\nMasukkan kertas pilihan anda :");
scanf("%i",&pil);
switch(pil)
{
case 1: kertas_f4();
getch();
goto x;
break;
case 2: kertas_A5();
getch();
goto x;
break;
case 3: kertas_A4();
getch();
goto x;
break;
case 4: kertas_A3();
getch();
goto x;
break;
case 5:{
clrscr();gotoxy(16,12);printf("Created By Afrinaldi And Jefri Rajif PTI 2010");}
break;
default : printf("\ninputan salah");getch();
goto x;
}
getch();
}






9 komentar:

  1. GILAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... KEREEEENN :O :O :O

    gotoxy itu apa sih? Waktu aku masih semester 2, masih simple banget. Bahkan di kampusku ga belajar pascal.

    BalasHapus
  2. Thanks Bro.. :)

    gotoxy tu untuk menentukan letak koordinat.. di x(kolom) mana, y(baris) mana..

    Kalau kami pertamanya belajar pascal dulu, baru deh bahasa C..

    BalasHapus
  3. wah, dua orang ahli informatika lagi kumpul... #SujudSembah...

    BalasHapus
  4. @Nanda: Saya bukan ahli informatika.. Saya Ahli Surga.. Amin Ya Allah.. :D

    BalasHapus
  5. aduh aku gak ngerti..
    aku masih sd kakak :3
    huehehehe :D

    BalasHapus
  6. @Indra: HHehehe. Anak SD kok kayak udah SMA y?? Boros nih wajahnya.. Hehehe. Peace

    BalasHapus
  7. Liat postingan ini jadi inget mantan cyberlove gw :(
    *cyberlove 2007-2009*

    BalasHapus
  8. @Yohanes: cyberlove?? Siapa?? Pascal??

    BalasHapus