/* #--------------------------------- # Program Diskon #--------------------------------- Ket : nb = Nama barang jb = jumlah barang kb = Kode barang tp = total pembelian hb = Harga barang by = bayar Jika Harga di atas Rp.500.000 Diskon 1% Jika Harga di atas Rp.300.000 Diskon 0.5% Jika Harga di atas Rp.100.000 Diskon 0.3% Total Pembelian : Harga Barang X Jumlah barang Harga bayar : Total Pembelian - Diskon Potongan harga : Total pembelian / Diskon */ #include<stdio.h> #include<conio.h> #include<iostream.h> void main() { long int hb,jb,tp,by; float ds; char nb[50]; char kb[50]; clrscr(); printf("Nama Barang : ");scanf("%s",&nb); printf("Kode Barang : ");scanf("%s",&kb); printf("Harga Barang : ");scanf("%ld",&hb); printf("Jumlah Barang : ");scanf("%ld",&jb); printf("------------------------------------------\n"); tp=hb*jb; printf("Totap Pembelian : %ld",tp); if (tp>500000) ds=0.1*tp; else if(tp>300000) ds=0.05*tp; else if(tp>100000) ds=0.003*tp; by=tp-ds; printf("\nBayar : %ld",by); printf("\nPotongan Harga : %f",ds); getch(); }
Program Diskon Part II
/* Program Diskon Part II Ket : nb = Nama barang tb : total bayar hb = Harga barang tds : Total Diskon jb = Jumlah barang ds : Diskon Total Pembelian : Harga barang X Jumlah barang Total Diskon : Total Pembelian X Diskon / 100 Total Bayar : Total pembelian - Total Diskon */ #include<stdio.h> #include<conio.h> #include<iostream.h> void main() { long int hb,jb,tb,th,tp,ds; float tds; char nb[50]; clrscr(); printf("Input Nama Barang : ");scanf("%s",&nb); printf("Input Harga Barang : Rp.");scanf("%ld",&hb); printf("Input Jumlah Barang : ");scanf("%ld",&jb); printf("Input Diskon : ");scanf("%ld",&ds); printf("---------------------------------------"); tp=hb*jb; printf("\nTotal Pembelian = Rp.%ld",tp); tds=tp*ds/100; printf("\nTotal Diskon = %f",tds); tb=tp-tds; printf("\nTotal Bayar = Rp.%ld",tb); getch(); }