3. Acknowledgement
I thank my Computer Science teacher Mr.
Murli Manohar for guidance and support. I also
thank my Principal Ms. N. Geeta Rao. I would
also like to thank my parents for encouraging
me during the whole course of this project.
Finally I would like to thank CBSE for giving
me such opportunity to undertake this esteem
project.
3
4. Certificate
This is to certify that PRANAV
GHILDIYAL of class XII B, KENDRIYA
VIDYALAYA B.E.G has successfully completed
his project in computer practicals for the
AISSCE as prescribed by CBSE FOR the year
2013-2014.
Date :
Signature of Internal
Examiner
Signature of External
Examiner
__________________
__________________
4
5. HEADER FILES USED
AND THEIR PURPOSE
1.
CONIO.H
- for clrscr(), getch() functions
2.
STDIO.H
- Standard I/O Operations
3.
PROCESS.H
- for exit() function
4.
FSTREAM.H - for data file handling operations
5.
STDLIB.H
- for random() function
5
8. //***************************************************************
//
HEADER FILE USED IN PROJECT
//****************************************************************
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<fstream.h>
#include<stdlib.h>
//***************************************************************
//
CLASSES USED IN PROJECT
//****************************************************************
class product
{ int pno;
char name[30];
float price;
public:
void create_product()
{
cout<<"n Please Enter The Product No. of The Product : ";
cin>>pno;
cout<<"nn Please Enter The Name of The Product : ";
gets(name);
cout<<"n Please Enter The Price of The Product : ";
cin>>price;
}
void show_product()
{
cout<<"n The Product No. of The Product : "<<pno;
cout<<"n The Name of The Product : ";
puts(name);
cout<<"n The Price of The Product : "<<price;
}
int retpno() { return pno; }
float retprice() { return price; }
char* retname() { return name; }
};
// End Of Class
//***************************************************************
//
global declaration for stream object, object
//****************************************************************
fstream fp;
product pr;
//***************************************************************
//
function to write in file
//****************************************************************
void write_product()
{
fp.open("Shop.dat",ios::app);
pr.create_product();
fp.write((char*)&pr,sizeof(product));
fp.close();
cout<<"nn The Product Has Been Created ";
getch();
8
9. }
//***************************************************************
//
function to read all records from file
//****************************************************************
void display_all()
{
clrscr();
cout<<"nnntt DISPLAY ALL RECORD !!!nn";
fp.open("Shop.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
{
pr.show_product();
cout<<"nn====================================n";
getch();
}
fp.close();
getch();
}
//***************************************************************
//
function to read specific record from file
//****************************************************************
void display_sp(int n)
{
int flag=0;
fp.open("Shop.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
{
if(pr.retpno()==n)
{
clrscr();
pr.show_product();
flag=1;
}
}
fp.close();
if (flag==0)
cout<<"nn record not exist";
getch();
}
//***************************************************************
//
function to modify record of file
//****************************************************************
void modify_product()
{
int no, found=0;
clrscr();
cout<<"nnt To Modify ";
cout<<"nnt Please Enter The Product No. of The Product";
cin>>no;
fp.open("Shop.dat",ios::in|ios::out);
while(fp.read((char*)&pr,sizeof(product)) && found==0)
{
if(pr.retpno()==no)
9
10. {
pr.show_product();
cout<<"n Please Enter The New Details of Product"<<endl;
pr.create_product();
int pos=-1*sizeof(pr);
fp.seekp(pos,ios::cur);
fp.write((char*)&pr,sizeof(product));
cout<<"nnt Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"nn Record Not Found ";
getch();
}
//***************************************************************
//
function to delete record of file
//****************************************************************
void delete_product()
{ int no;
clrscr();
cout<<"nnnt Delete Record";
cout<<"nn Please Enter The product no. of The Product You Want To Delete";
cin>>no;
fp.open("Shop.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&pr,sizeof(product)))
{
if(pr.retpno()!=no)
{
fp2.write((char*)&pr,sizeof(product));
}
}
fp2.close();
fp.close();
remove("Shop.dat");
rename("Temp.dat","Shop.dat");
cout<<"nnt Record Deleted ..";
getch();
}
//***************************************************************
//
function to display all products price
list //****************************************************************
void menu()
{
clrscr();
fp.open("Shop.dat",ios::in);
if(!fp)
{
10
11. cout<<"ERROR!!! FILE COULD NOT BE OPENnnn Go To Admin Menu to
create File";
cout<<"nnn Program is closing ....";
getch();
exit(0);
}
cout<<"nntt Product MENUnn";
cout<<"====================================================n";
cout<<"P.NO.tt NAMEttt PRICEn";
cout<<"====================================================n";
while(fp.read((char*)&pr,sizeof(product)))
{
cout<<pr.retpno()<<"tt"<<pr.retname()<<"tt"<<pr.retprice()<<endl;
}
cout<<"====================================================n";
fp.close();
}
//***************************************************************
//
function to generate discount
//****************************************************************
void disc_app(int total)
{
randomize();
int disc=0, tbpamt=total, rnum2=0;
int SPNUM[9]= { 1,5,6,13,29,43,73,91,96};
if (total < 1000)
cout<<” n n Amount to be paid after discount : - Rs. "<<tbpamt;
if (total >=1000)
{
if ((total%2 ==1) && (total %5 ==0))
disc =random (90);
tbpamt = total - ((disc*total)/100);
cout<<" n n Amount to be paid after discount : - Rs. "<<tbpamt;
}
else
{
rnum2= random(SPNUM[9]);
if ( (rnum2 == 1) ||(rnum2 == 6) || (rnum2 ==29) )
tbpamt = total - (0.25*total);
else if ( (rnum2 == 5) ||(rnum2 == 13) || (rnum2 ==91) )
tbpamt = total - (0.5*total);
else if ( (rnum2 == 43) ||(rnum2 == 73) || (rnum2 ==96) )
tbpamt = total - (0.3*total);
cout<<"nn Amount to be paid after discount"<<tbpamt;
}
getch();
}
//***************************************************************
//
function to place order and generating bill for Products
11
12. //****************************************************************
void place_order()
{
int order_arr[50],quan[50],c=0, ic = 0;
float amt,total=0;
char ch='Y';
menu();
cout<<"nn";
cout<<"n PLACE YOUR ORDER";
cout<<"nnnn";
do{
cout<<"nn Enter The Product No. Of The Product : ";
cin>>order_arr[c];
cout<<"Quantity in number : ";
cin>>quan[c], ic +=quan[c];
c++;
cout<<"Do You Want To Order Another Product ? (y/n)";
cin>>ch;
}while(ch=='y' ||ch=='Y');
cout<<"nnThank You For Placing The Order";
getch();
clrscr();
cout<<"nnn";
cout<<"nn********************************INVOICE*******************
*****n";
cout<<"Pr No.t Pr Namett Quantity t Price t Amountn";
cout<<"**************************************************************
*n";
for(int x=0;x<=c; x++)
{
fp.open("Shop.dat",ios::in);
fp.read((char*)&pr,sizeof(product));
while(!fp.eof())
{
if(pr.retpno()==order_arr[x])
{
amt=pr.retprice()*quan[x];
cout<<"n"<<order_arr[x]<<"t"<<pr.retname()<<"t"<<quan[x]<<"tt"<<pr.retprice(
)<<"t"<<amt;
total+=amt;
}
fp.read((char*)&pr,sizeof(product));
}
fp.close();
}
12
13. cout<<"n"<<"*********************************************************
******";
cout<<"n Items count:-"<<ic<<"tttt"<<"Bill Amount:-"<<total;
getch();
disc_app(total);
}
//***************************************************************
//
INTRODUCTION FUNCTION
//****************************************************************
void intro()
{
clrscr();
gotoxy(30,15);
cout<<"n======================================================
=======";
cout<<"n"<<"|"<<" Welcome to purchase corner of Shopping Mall
|";
cout<<"n"<<"|"<<" MADE BY : Pranav & Kausal
|";
cout<<"n"<<"|"<<" SCHOOL : Kendriya Vidyalaya B.E.G.
|";
cout<<"n"<<"==================================================
===========";
getch();
}
//***************************************************************
//
ADMINSTRATOR MENU FUNCTION
//****************************************************************
void admin_menu()
{
clrscr();
char ch2;
cout<<"###############################################";
cout<<"nnnt ADMINISTRATOR MENU";
cout<<"nnt1.CREATE PRODUCT";
cout<<"nnt2.DISPLAY ALL PRODUCTS";
cout<<"nnt3.QUERY ";
cout<<"nnt4.MODIFY PRODUCT";
cout<<"nnt5.DELETE PRODUCT";
cout<<"nnt6.VIEW PRODUCT MENU";
cout<<"nnt7.BACK TO MAIN MENU";
cout<<"nnt Please Enter Your Choice (1-8) ";
cout<<"n################################################";
ch2=getche();
cout<<"###############################################";
switch(ch2)
{
case '1': clrscr();
write_product();
break;
case '2': display_all();break;
13
14. case '3':
int num;
clrscr();
cout<<"nnt Please Enter The Product No. ";
cin>>num;
display_sp(num);
break;
case '4': modify_product();break;
case '5': delete_product();break;
case '6': menu();
getch();
case '7': break;
default: cout<<"a";admin_menu ();
}
}
//***************************************************************
//
THE MAIN FUNCTION OF PROGRAM
//****************************************************************
void main()
{
char ch;
intro();
do
{
clrscr();
cout<<"nnnt MAIN MENU";
cout<<"nnt01. CUSTOMER";
cout<<"nnt02. ADMINISTRATOR";
cout<<"nnt03. EXIT";
cout<<"nnt Please Select Your Option (1-3) ";
ch=getche();
switch(ch)
{
case '1': clrscr();
place_order();
getch();
break;
case '2': admin_menu();
break;
case '3':exit(0);
default :cout<<"a";
}
}while(ch!='3');
}
14
15. REQUIREMENTS
SOFTWARE REQUIRED
Operating system : Windows XP or later
Turbo C++, for execution of program and
MS Office, for presentation of output.
DISCLAIMER :I HAVE ALSO MADE THIS PROJECT
TAKING HELP FROM INTERNET
I EXPREE MY REGARDS WHO ARE
ACTUALLY BEHIND THIS PROJECT. I
HAVE UPLOADED THIS ONLY SO
THAT MORE PEOPLE CAN TAKE HELP
FROM THIS UPLOAD THROUGH MY
PROFILE IN SLIDESHARE… TO
REGISTER YOUR OBJECTION TO THIS
UPLOAD PLZ COMMENT UNDER THE
PRESENTATION IN THE WEBSITE
15
16. BIBLIOGRAPHY
COMPUTER SCIENCE IN C++ BY :– SUMITA ARORA
(Class:- ‘XI’, ‘XII’)
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
16