Program penjualan barang dalam C++ dengan compiler borland sebagai berikut
#include <iostream>
#include <conio>
main(){
char barang[5]['a'];
int harga['a'];
int a, sisa, bayar;
int jum=0;
char pilih;
do{
clrscr();
cout<<"MASUKKAN JUMLAH BARANG:";cin>>a;
gotoxy(1,8+a);cout<<"TOTAL HARGA :";
gotoxy(1,10+a);cout<<"YANG DIBAYARKAN :";
gotoxy(1,12+a);cout<<"KEMBALIAN :";
gotoxy(1,14+a);cout<<"ADA TAMBAHAN(Y/T):";
for(int i=0;i<=39;i++){
gotoxy(1+i,3);textcolor(10);cprintf("=");
gotoxy(1+i,6+a);textcolor(10);cprintf("=");
}
gotoxy(1,4);cout<<"NO";
gotoxy(4,4);textcolor(10);cprintf("|");
gotoxy(7,4);cout<<"NAMA BARANG";
gotoxy(22,4);textcolor(10);cprintf("|");
gotoxy(26,4);cout<<"HARGA BARANG";
gotoxy(40,4);textcolor(10);cprintf("|");
for(int j=0;j<=39;j++){
gotoxy(1+j,5);textcolor(10);cprintf("=");
}
for(int k=0; k<a;k++){
gotoxy(4,6+k);textcolor(10);cprintf("|");
gotoxy(22,6+k);textcolor(10);cprintf("|");
gotoxy(40,6+k);textcolor(10);cprintf("|");
}
for(int m=0;m<a;m++){
gotoxy(2,6+m);cout<<m+1;
}
for(int l=0;l<a;l++){
gotoxy(7,6+l);cin>>barang[l];
gotoxy(26,6+l);cin>>harga[l];
jum=jum+harga[l];
}
gotoxy(26,8+a);cout<<"Rp "<<jum;
gotoxy(26,10+a);cout<<"Rp ";cin>>bayar;
sisa=bayar-jum;
gotoxy(26,12+a);cout<<"Rp "<<sisa;
gotoxy(26,14+a);cin>>pilih;
}
while(pilih=='y'||pilih=='Y');
getch();
}
Kamis, 19 Mei 2011
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar