#include
#include
#include
#include
#include
struct aby{
char * diskonstr;
float diskon;
float hb;
float hj;
};
pur(float h)
{
float disk;
if(h < 1000000)
disk= (h * 10) / 100;
else if(h >= 1000000 && h <= 5000000)
disk = (h * 20) / 100;
else if(h > 5000000)
disk = (h * 25) / 100;
return disk;
}
main(){
float diskon[100],hb[100],hj[100];
int r = 0, index = 0, i = 0;//LOOPING
char b[20][100]; char tmp[10],ds[100][4];
float h[100];
while(r != 3){//loop
clrscr();
cout<<"---------------------------------------------------------------------\n";
cout<<" PROGRAM DATA BARANG\n";
cout<<"---------------------------------------------------------------------\n";
cout<<" PURYADI 10201506 \n";
cout<<"---------------------------------------------------------------------\n\n";
cout<<" MENU:\n";
cout<<"------------------\n\n";
cout<<" 1. Input Data\n 2. Cetak Laporan\n 3. Exit\n\nMasukkan Pilihan[1/2/3]: ";gets(tmp);r = atoi(tmp);
switch(r){
case 1://INPUT DATA
char lagi;
while (lagi!='t')
{ clrscr();
cout<<" -----------(Input Data)----------\n";
//cout<<"-----------------------------------\n";
cout<<" Nama Barang: "; gets(b[i]);
cout<<" Harga : "; gets(tmp);
h[i] = atof(tmp);
diskon[i]=pur(h[i]);
hj[i]=h[i]-diskon[i];
//ds[i]=x(h[i]);
cout< i++;
cout<<"Apakah akan mengisi lagi?(y/t): "; lagi=getch();
}
break;
case 2:
int k = 4;
while(k != 0 && k != 3)
{
clrscr();
// cout<<"-----------(Cetak Barang)----------\n";
//cout<<"-----------------------------------\n";
printf("-----------------------------------------------------------\n");
printf("|Nama barang |Harga beli |Diskon |Harga jual\n");
printf("-----------------------------------------------------------\n");
for(index = 0; index < i; index++)
{
gotoxy(4,4+index),printf("%s", b[index]);
gotoxy(18,4+index),printf("%0.2f",h[index]);
gotoxy(32,4+index),printf("%0.2f",diskon[index]);
if (diskon[index]<1000000)
gotoxy(42,4+index),printf("(10%)");
else if (diskon[index]>=1000000 ||diskon[index]<= 5000000 )
gotoxy(42,4+index),printf("(20%)");
else if(diskon[index]>5000000 )
gotoxy(42,4+index),printf("(25%)") ;
gotoxy(50,4+index),printf("%0.2f",hj[index]);
}
printf("\n-----------------------------------------------------------\n");
cout<<"\n\nKembali[0], Exit[3]: "; cin>>k;
if(k == 0)
r = 0;
else if(k == 3)
r = 3;
}
break;
}
}
}
#include
#include
#include
#include
struct aby{
char * diskonstr;
float diskon;
float hb;
float hj;
};
pur(float h)
{
float disk;
if(h < 1000000)
disk= (h * 10) / 100;
else if(h >= 1000000 && h <= 5000000)
disk = (h * 20) / 100;
else if(h > 5000000)
disk = (h * 25) / 100;
return disk;
}
main(){
float diskon[100],hb[100],hj[100];
int r = 0, index = 0, i = 0;//LOOPING
char b[20][100]; char tmp[10],ds[100][4];
float h[100];
while(r != 3){//loop
clrscr();
cout<<"---------------------------------------------------------------------\n";
cout<<" PROGRAM DATA BARANG\n";
cout<<"---------------------------------------------------------------------\n";
cout<<" PURYADI 10201506 \n";
cout<<"---------------------------------------------------------------------\n\n";
cout<<" MENU:\n";
cout<<"------------------\n\n";
cout<<" 1. Input Data\n 2. Cetak Laporan\n 3. Exit\n\nMasukkan Pilihan[1/2/3]: ";gets(tmp);r = atoi(tmp);
switch(r){
case 1://INPUT DATA
char lagi;
while (lagi!='t')
{ clrscr();
cout<<" -----------(Input Data)----------\n";
//cout<<"-----------------------------------\n";
cout<<" Nama Barang: "; gets(b[i]);
cout<<" Harga : "; gets(tmp);
h[i] = atof(tmp);
diskon[i]=pur(h[i]);
hj[i]=h[i]-diskon[i];
//ds[i]=x(h[i]);
cout<
cout<<"Apakah akan mengisi lagi?(y/t): "; lagi=getch();
}
break;
case 2:
int k = 4;
while(k != 0 && k != 3)
{
clrscr();
// cout<<"-----------(Cetak Barang)----------\n";
//cout<<"-----------------------------------\n";
printf("-----------------------------------------------------------\n");
printf("|Nama barang |Harga beli |Diskon |Harga jual\n");
printf("-----------------------------------------------------------\n");
for(index = 0; index < i; index++)
{
gotoxy(4,4+index),printf("%s", b[index]);
gotoxy(18,4+index),printf("%0.2f",h[index]);
gotoxy(32,4+index),printf("%0.2f",diskon[index]);
if (diskon[index]<1000000)
gotoxy(42,4+index),printf("(10%)");
else if (diskon[index]>=1000000 ||diskon[index]<= 5000000 )
gotoxy(42,4+index),printf("(20%)");
else if(diskon[index]>5000000 )
gotoxy(42,4+index),printf("(25%)") ;
gotoxy(50,4+index),printf("%0.2f",hj[index]);
}
printf("\n-----------------------------------------------------------\n");
cout<<"\n\nKembali[0], Exit[3]: "; cin>>k;
if(k == 0)
r = 0;
else if(k == 3)
r = 3;
}
break;
}
}
}
Tidak ada komentar:
Posting Komentar
terimakasih aras kunjungan anda di blog mesujiraya
komentarnya saya tunggu mas bro & mbak sist