PROGRAM PENJUALAN LAPTOP
Assalamualaikum
wr wb. Selamat malam kaula mudaaa J, ketemu
lagi di blog akuuu, kali ini aku mau sedikit bagi ilmu.
Langsung
saja, postingan saya kali ini adalah tentang “PROGRAM PENJUALAN LAPTOP” menggunakan :
array, struct dan function, juga beberapa fungsi lainnya. Program ini dibuat
dengan menggunakan bahasa C dan aplikasi code block.
Berikut
programnya :
#include
<stdio.h>
#include
<conio.h>
#include
<string.h>
#include
<windows.h>
COORD
kordinat={0,0};
void
gotoxy(int x, int y)
{
kordinat.X=x;
kordinat.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),kordinat);
}
struct
datalaptop
{
char *merek, *tipe;
int harga, total;
int jumlah;
};
struct
datalaptop data[20];//array of record
int
i,n,no, bayar, kembali;
int
total_biaya=0;
void
jual();
void
daftar()
{
system("cls");
printf("+==============================================+\n");
printf("| No | Merek
| Tipe |
Harga |\n");
printf("|==============================================|\n");
printf("| 1 |
| Aspire 4743 | Rp. 4500000
|\n");
printf("| 2 |
Acer | Aspire One | Rp. 3500000 |\n");
printf("| 3 |
| Aspire V3 | Rp. 3399000 |\n");
printf("|----|------------|-------------|--------------|\n");
printf("| 4 |
|ASUS X200MA | Rp. 3099000 |\n");
printf("| 5 |
Asus |E1-7010 White| Rp.
3599000 |\n");
printf("| 6 |
|A6-7310 White| Rp. 4299000
|\n");
printf("|----|------------|-------------|--------------|\n");
printf("+==============================================+\n");
jual();
getch();
}
void
jual()
{
int no;
i=1;
char lagi;
do{
//int i=1;
printf("\nInput no laptop : ");
scanf("%d",&no);
if (no==1)
{
data[i].merek="Acer";
data[i].tipe="Aspire 4743";
data[i].harga=4500000;
printf("Merek : %s\n",data[i].merek);
printf("Tipe : %s\n",data[i].tipe);
printf("Harga : %d\n",data[i].harga);
printf("Jumlah : ");
scanf("%d",&data[i].jumlah); fflush(stdin);
data[i].total=data[i].harga*data[i].jumlah;
total_biaya=data[i].total+total_biaya;
n=n+1;
} else
if (no==2)
{
data[i].merek="Acer";
data[i].tipe="Aspire One";
data[i].harga=3500000;
printf("Merek : %s\n",data[i].merek);
printf("Tipe : %s\n",data[i].tipe);
printf("Harga : %d\n",data[i].harga);
printf("Jumlah : ");
scanf("%d",&data[i].jumlah); fflush(stdin);
data[i].total=data[i].harga*data[i].jumlah;
total_biaya=data[i].total+total_biaya;
n=n+1;
}else
if (no==3)
{
data[i].merek="Acer";
data[i].tipe="Aspire V3";
data[i].harga=3399000;
printf("Merek : %s\n",data[i].merek);
printf("Tipe : %s\n",data[i].tipe);
printf("Harga : %d\n",data[i].harga);
printf("Jumlah : ");
scanf("%d",&data[i].jumlah); fflush(stdin);
data[i].total=data[i].harga*data[i].jumlah;
total_biaya=data[i].total+total_biaya;
n=n+1;
}else
if (no==4)
{
data[i].merek="Asus";
data[i].tipe="ASUS X200MA";
data[i].harga=3099000;
printf("Merek : %s\n",data[i].merek);
printf("Tipe : %s\n",data[i].tipe);
printf("Harga : %d\n",data[i].harga);
printf("Jumlah : "); scanf("%d",&data[i].jumlah);
fflush(stdin);
data[i].total=data[i].harga*data[i].jumlah;
total_biaya=data[i].total+total_biaya;
n=n+1;
}else
if (no==5)
{
data[i].merek="Asus";
data[i].tipe="E1-7010
White";
data[i].harga=3599000;
printf("Merek : %s\n",data[i].merek);
printf("Tipe : %s\n",data[i].tipe);
printf("Harga : %d\n",data[i].harga);
printf("Jumlah : ");
scanf("%d",&data[i].jumlah); fflush(stdin);
data[i].total=data[i].harga*data[i].jumlah;
total_biaya=data[i].total+total_biaya;
n=n+1;
}else
if (no==6)
{
data[i].merek="Asus";
data[i].tipe="A6-7310
White";
data[i].harga=4299000;
printf("Merek : %s\n",data[i].merek);
printf("Tipe : %s\n",data[i].tipe);
printf("Harga : %d\n",data[i].harga);
printf("Jumlah : ");
scanf("%d",&data[i].jumlah); fflush(stdin);
data[i].total=data[i].harga*data[i].jumlah;
total_biaya=data[i].total+total_biaya;
n=n+1;
}
i++;
//total_biaya=data[i].total;
printf("\nBeli lagi (Y/T) : ");
scanf("%s",&lagi); //fflush(stdin);
}while (lagi!='T');
getch();
}
void
output()
{
system("cls");
printf("+==========================================================================+\n");
printf("| No | Merek
| Tipe |
Harga | Jumlah | Total |\n");
printf("|-------------------------------------------------------|------------------|\n");
for(i=1;i<=n;i++)
{
printf("| | | | | | Rp. |\n");
gotoxy(3, i+2);
printf("%d\n",i);
gotoxy(8, i+2);
printf("%s\n", data[i].merek);
gotoxy(20, i+2);
printf("%s\n", data[i].tipe);
gotoxy(35, i+2);
printf("%d\n", data[i].harga);
gotoxy(50, i+2);
printf("%d\n", data[i].jumlah);
gotoxy(62, i+2);
printf("%d\n", data[i].total);
//n=1;
}
printf("|-------------------------------------------------------|------------------|\n");
printf("|
Total Biaya | Rp.
|\n");
printf("|-------------------------------------------------------|------------------|\n");
printf("|
Pembayaran | Rp. |\n");
printf("|
Kembalian | Rp. |\n");
printf("+==========================================================================+\n");
gotoxy(62, i+3); printf("%d\n",
total_biaya);
gotoxy(62, i+5); scanf("%i",
&bayar);
if(bayar<total_biaya){
gotoxy(62,
i+6);printf("--------");
gotoxy(30, i+8);printf("Maaf,
uang anda tidak mencukupi");
}
else
{
kembali=bayar-total_biaya;fflush(stdin);
gotoxy(62, i+6);printf("%d",
kembali);
}
getch();
}
void
main()
{
int pil;
do{
system("cls");
printf("+================================+\n");
printf("| PENJUALAN LAPTOP |\n");
printf("|--------------------------------|\n");
printf("| 1. Daftar Laptop |\n");
printf("| 2. Tampilkan hasil
penjualan |\n");
printf("| 0. Keluar |\n");
printf("|--------------------------------|\n");
printf("| Pilih menu : |\n");
printf("+================================+\n");
gotoxy(15,7);
scanf("%d",&pil);
switch(pil)
{
case 1 : {daftar(); break;}
case 2 : {output(); break;}
case 0 : break;
default : gotoxy(1,9);
printf("Pilihan salah"); getch();
}
}while (pil!=0);
}
|
Demikian, Terimakasih dan semoga bermanfaat :)
Wassalamualaikum wr wb.
0 komentar:
Posting Komentar