#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <iostream.h>
#include <cstring.h>
luk(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],h[100],hb[100],hj[100],total,bayar,kembali;
int r = 0, index = 0, i = 0;
char b[100][20],tmp[10];
while(r != 3){
clrscr();
cout<<" \n";
cout<<" UTS \n";
cout<<" PROGRAM DATA BARANG \n";
cout<<" ------------------------------------------\n";
cout<<" LUQMAN SYAIFUL A. 10201417 \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);
//atoi =str-int
//atof=str-float
switch(r){
case 1:
char lagi; lagi='p';
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]=luk(h[i]);
hj[i]=h[i]-diskon[i];
//ds[i]=x(h[i]);
cout<<endl<< diskon[i] <<endl;
i++;
cout<<"Apakah akan mengisi lagi?(y/t): "; lagi=getch();
}
break; //keluar
case 2:
// int k = 4;
// while(k != 0 && k != 3)
//{
kembali=-1;
while (kembali <0 )
{
clrscr();
printf("--------------------------------------------------------------\n");
printf("|Nama barang| |Harga beli| |Diskon| |Harga jual|\n");
printf("==============================================================\n");
total=0;
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]);
total=total+hj[index];
}
printf("\n--------------------------------------------------------------------------------\n");
gotoxy(50,6+index),printf("%0.2f",total);
gotoxy(30,6+index),printf("Total bayar");
gotoxy(30,8+index),printf("Uang tunai");
gotoxy(50,8+index),gets(tmp);
bayar=atof(tmp);
kembali=bayar-total;
// kembali=-1;
// while (kembali <0 )
// {
}
gotoxy(30,9+index),printf("Kembali");
gotoxy(50,9+index),printf("%0.2f",kembali);
gets(tmp);
}
}
// getch();
}
#include <conio.h>
#include <stdlib.h>
#include <iostream.h>
#include <cstring.h>
luk(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],h[100],hb[100],hj[100],total,bayar,kembali;
int r = 0, index = 0, i = 0;
char b[100][20],tmp[10];
while(r != 3){
clrscr();
cout<<" \n";
cout<<" UTS \n";
cout<<" PROGRAM DATA BARANG \n";
cout<<" ------------------------------------------\n";
cout<<" LUQMAN SYAIFUL A. 10201417 \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);
//atoi =str-int
//atof=str-float
switch(r){
case 1:
char lagi; lagi='p';
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]=luk(h[i]);
hj[i]=h[i]-diskon[i];
//ds[i]=x(h[i]);
cout<<endl<< diskon[i] <<endl;
i++;
cout<<"Apakah akan mengisi lagi?(y/t): "; lagi=getch();
}
break; //keluar
case 2:
// int k = 4;
// while(k != 0 && k != 3)
//{
kembali=-1;
while (kembali <0 )
{
clrscr();
printf("--------------------------------------------------------------\n");
printf("|Nama barang| |Harga beli| |Diskon| |Harga jual|\n");
printf("==============================================================\n");
total=0;
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]);
total=total+hj[index];
}
printf("\n--------------------------------------------------------------------------------\n");
gotoxy(50,6+index),printf("%0.2f",total);
gotoxy(30,6+index),printf("Total bayar");
gotoxy(30,8+index),printf("Uang tunai");
gotoxy(50,8+index),gets(tmp);
bayar=atof(tmp);
kembali=bayar-total;
// kembali=-1;
// while (kembali <0 )
// {
}
gotoxy(30,9+index),printf("Kembali");
gotoxy(50,9+index),printf("%0.2f",kembali);
gets(tmp);
}
}
// getch();
}
0 comments:
Post a Comment