Nota Belanja
contoh source code nota belanja :)
#include <stdio.h>
struct dok{
int diskon,hrg,sum;
char ukuran;
};
void input(struct dok[]);
void size(char);
int hrg_awal(struct dok[]);
void nota(struct dok[]);
int diskon(struct dok[]);
int i=0,tot_byr=0,pajak=0,tot_diskon=0;
int main()
{
struct dok beli[1000];
int bnyk;
printf("\t\t\t\t~ TOKO LARIS ~\n");
printf("\t\t\t\tDaftar Harga\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("Ukuran Baju\t\t\tNama Ukuran\t\tHarga per Potong\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\tS\t\t\tSmall\t\t\tRp 36.000,-\n");
printf("\tM\t\t\tMedium\t\t\tRp 43.000,-\n");
printf("\tL\t\t\tLarge\t\t\tRp 62.000,-\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("Dapatkan diskon 20%% untuk pembelian lebih dari 10 potong....\n");
printf("jangan lupa pajak yaaa.... (10%% x <harga - diskon > \n\n");
printf("Berapa jumlah data [maks 3] ? ");
scanf("%d",&bnyk);
while(i<bnyk&&i<3)
{
fflush(stdin);
input(beli);
i++;
}
nota(beli);
}
void input(struct dok a[])
{
printf("\nUkuran [S/M/L]\t: ");
scanf("%c",&a[i].ukuran);
printf("Jumlah helai\t: ");
scanf("%d",&a[i].sum);
a[i].hrg=hrg_awal(a);
a[i].diskon=diskon(a);
}
void nota(struct dok a[])
{
int j=0;
printf("\n\n\t\t\t**NOTA BELANJA**\n\n");
printf("\t\t\t\tTOKO LARIS\n");
printf("===============================================================================\n");
printf("No\tNama ukuran\tHarga Satuan\tJumlah\tDiskon\t\tJumlah Harga\n");
printf("===============================================================================\n");
for(j;j<i;j++)
{
printf("%d\t",j+1);
size(a[j].ukuran);
tot_byr=tot_byr+a[j].hrg-a[j].diskon;
tot_diskon=tot_diskon+a[j].diskon;
printf("%d\tRp %d\tRp %d,00\n",a[j].sum,a[j].diskon,a[j].hrg-a[j].diskon);
}
printf("------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\tJumlah bayar\tRp %d,00\n",tot_byr);
printf("\t\t\t\t\t\tPajak 10%%\tRp %d,00\n",tot_byr*10/100);
printf("\t\t\t\t\t\tTOTAL BAYAR\tRp %d,00\n",tot_byr-(tot_byr*10/100));
}
void size(char a)
{
switch (a)
{
case 's':
case 'S':printf("Small\t\tRp 36.000,00\t");
break;
case 'm':
case 'M':printf("Medium\t\tRp 43.000,00\t");
break;
case 'l':
case 'L':printf("Large\t\tRp 62.000,00\t");
break;
}
}
int diskon(struct dok a[])
{
if(a[i].sum>10)
{
return a[i].hrg*20/100;
}
else
{
return 0;
}
}
int hrg_awal(struct dok a[])
{
if(a[i].ukuran=='s'||a[i].ukuran=='S')
{
return a[i].sum*36000;
}
else if(a[i].ukuran=='m'||a[i].ukuran=='M')
{
return a[i].sum*43000;
}
else if(a[i].ukuran=='L'||a[i].ukuran=='l')
{
return a[i].sum*62000;
}
}
int tot_hrg(struct dok a[])
{
return a[i].hrg-a[i].diskon;
}
hasil outputnya seperti ini nih :)
0 komentar: