Code:
#define num 4
#define length 100
#include<stdio.h>
void fiction();
void art();
void engin();
void child();
void study();
void display(float p,char books[][],price[]);
int main()
{
char option,ans,wey;
float total=0.0,a=0.0,b=0.0,c=0.0,d=0.0,e=0.0;
printf("WELCOME TO ONLINEBUKU.COM\n\a");
printf("WHICH CATEGORY YOU WANT TO CHOOSE?\n");
printf(" A: FICTION BOOKS\n");
printf(" B: ART AND CRAFT BOOKS\n");
printf(" C: ENGINEERING & SCIENCE BOOKS\n");
printf(" D: CHILDREN BOOKS\n");
printf(" E: ISLAMIC STUDIES BOOKS\n");
do
{
printf("\n");
printf("YOUR OPTION:\a");
scanf("%c",&option);
printf("\n");
switch(option)
{
case 'A': a=fiction(q);break;
case 'a': a=fiction(q);break;
case 'B': b=art(v);break;
case 'b': b=art(v);break;
case 'C': c=engin(w);break;
case 'c': c=engin(w);break;
case 'D': d=child(x);break;
case 'd': d=child(x);break;
case 'E': e=study(y);break;
case 'e': e=study(y);break;
}
total= a+b+c+d+e;
fflush(stdin);
printf("\tPress Y to continue:\a");
scanf("%c",&ans);
fflush(stdin);
}while(ans=='Y'||ans=='y');
display(total);
system("pause");
return 0;
}
void fiction()
{
char books[num][length]={"Zeus King Of The Gods","Penny Century","Map of the Invisible World","Jodi Picoult: House Rules"};
char wey;
float price[num]={ 58.20,78.90,34.60,32.90 };
float total=0.0;
do
{
int books,amount,i;
float total=0.0;
printf("\tOPTION A: FICTION BOOKS \t\t PRICE (UNIT)\n");
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\t1.Zeus King Of The Gods RM 58.20\n");
printf("\t2.Penny Century RM 78.90\n");
printf("\t3.Map of the Invisible World RM 34.60\n");
printf("\t4.Jodi Picoult: House Rules RM 32.90\n");
printf("\tPlease key in your choice:");
scanf("%d",&books);
printf("\tPlease enter the amount:");
scanf("%d",&amount);
for( i=0 ; i<4 ; i++ )
{
total+=price[i]*amount;
}
printf("\tThe total price is RM%0.2f\n",total);
printf("\tEnter R if you want to choose within the same category:");
scanf("%s", &wey);
printf("\n");
}while(wey=='r' ||wey=='R');
display(total,char books[i][length],price[i]);
}
void art()
{
char books[num][length]={"Connoisseur'S Guide To Antique Silver","Best Ever Craft Project Book","Encyclopedia Of Acrylic Techni Ques","Teach Yourself Calligraphy"};
char wey;
float price[num]={58.20,38.50,89.60,100.50};
float total= 0.0;
do
{
int books,amount,i;
float total=0.0;
printf("\tOPTION B: ART AND CRAFT BOOKS \t\tPRICE (UNIT)\n");
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\t1.Connoisseur'S Guide To Antique Silver RM 58.20\n");
printf("\t2.Best Ever Craft Project Book RM 38.50\n");
printf("\t3.Encyclopedia Of Acrylic Techni Ques RM 89.60\n");
printf("\t4.Teach Yourself Calligraphy RM 100.50\n");
printf("\tPlease key in your choice:");
scanf("%d",&books);
printf("\tPlease enter the amount:");
scanf("%d",&amount);
for( i=0 ; i<4 ; i++ )
{
total+=price[i]*amount;
}
printf("\tThe total price is RM%0.2f\n",total);
printf("\tEnter R if you want to choose within the same category:");
scanf("%s", &wey);
printf("\n");
}while(wey=='r' ||wey=='R');
display(total,char books[i][length],price[i]);
}
void engin()
{
char books[num][length]={"Solar Power For Your Home","Chemical Engineering Thermodynamic","Marine Electrical Technology","Engineering Design Reliability"};
char wey;
float price[num]={71.80,69.90,128.60,112.90};
float total= 0.0;
do
{
int books,amount,i;
float total=0.0;
printf("\tOPTION C: ENGINEERING & SCIENCE BOOKS PRICE (UNIT)\n");
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\t1.Solar Power For Your Home RM 71.80\n");
printf("\t2.Chemical Engineering Thermodynamic RM 69.90\n");
printf("\t3.Marine Electrical Technology RM 128.60\n");
printf("\t4.Engineering Design Reliability RM 112.90\n");
printf("\tPlease key in your choice:");
scanf("%d",&books);
printf("\tPlease enter the amount:");
scanf("%d",&amount);
for( i=0 ; i<4 ; i++ )
{
total+=price[i]*amount;
}
printf("\tThe total price is RM%0.2f\n",total);
printf("\tEnter R if you want to choose within the same category:");
scanf("%s", &wey);
printf("\n");
}while(wey=='r' ||wey=='R');
display(total,char books[i][length],price[i]);
}
void child()
{
char books[num][length]={"Kasih Sahabat","Adikku Istimewa","101 Akhlak Rasulullah","Legasi Blok E: Kebangkitan Kuasa"};
char wey;
float price[num]={11.90,12.00,32.00,14.50};
float total= 0.0;
do
{
int books,amount,i;
float total=0.0;
printf("\tOPTION D: CHILDREN BOOKS \t PRICE (UNIT)\n");
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\t1. Kasih Sahabat RM 11.90\n");
printf("\t2. Adikku Istimewa RM 12.00\n");
printf("\t3. 101 Akhlak Rasulullah RM 32.00\n");
printf("\t4. Legasi Blok E: Kebangkitan Kuasa RM 14.50\n");
printf("\tPlease key in your choice:");
scanf("%d",&books);
printf("\tPlease enter the amount:");
scanf("%d",&amount);
for( i=0 ; i<4 ; i++ )
{
total+=price[i]*amount;
}
printf("\tThe total price is RM%0.2f\n",total);
printf("\tEnter R if you want to choose within the same category:");
scanf("%s", &wey);
printf("\n");
}while(wey=='r' ||wey=='R');
display(total,char books[i][length],price[i]);
}
void study()
{
char books[num][length]={"Mencari Islam di China","From Cat Steven to Yusuf Islam","Ketika Hatiku Ingin Berhijrah","Taatilah Allah, Rasul & Ulil Amri"};
char wey;
float price[num]={23.30,20.00,25.50,12.50};
float total= 0.0;
do
{
int books,amount,i;
float total=0.0;
printf("\tOPTION E: ISLAMIC STUDIES BOOKS \tPRICE (UNIT)\n");
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\t1. Mencari Islam di China RM 23.30\n");
printf("\t2. From Cat Steven to Yusuf Islam RM 20.00\n");
printf("\t3. Ketika Hatiku Ingin Berhijrah RM 25.50\n");
printf("\t4. Taatilah Allah, Rasul & Ulil Amri RM 12.50\n");
printf("\tPlease key in your choice:");
scanf("%d",&books);
printf("\tPlease enter the amount:");
scanf("%d",&amount);
for( i=0 ; i<4 ; i++ )
{
total+=price[i]*amount;
}
printf("\tThe total price is RM%0.2f\n",total);
printf("\tEnter R if you want to choose within the same category:");
scanf("%s", &wey);
printf("\n");
}while(wey=='r' ||wey=='R');
display(char books[i][length],price[i]);
}
void display(float p,char books[][],price[])
{
printf("\n");
printf("\t~~~~~~~~~~~~~~~ONLINEBUKU PAYMENT RECEIPT~~~~~~~~~~~~~~~\n");
printf("\n");
printf("\t\tTitle\t\tPrice\t\tTotal\n");
printf("\t\t%s\t\t%f\t\t%f\n",char books[][],price[],p);
printf("\n");
}
why the compiler kept displaying