Vous êtes sur la page 1sur 47

SUPER MARKET BILLING

FULL PROJECT ON

1
SUPER MARKET BILLING

STUDENT PROFILE

NAME :-) HIMANSHU PUROHIT

FATHER NAME :-) MR. SURESH PUROHIT

CLASS :-) 12th COMMERCE

MOBILE :- ) +919571571523

E-MAIL :-) Himanshur777@gmail.com

PROJECT TITLE :-) SUPER MARKET BILLING

2
SUPER MARKET BILLING

CERTIFICATE

This is to certify that Mr. HIMANSHU PUROHIT of


class 12th Commerce of
M.S.KAWAR.INTERNATIONAL.SCHOOL has
completed her project file under my supervision.
He has taken proper care and shown utmost
sincerity in completion of this project.
I certify that this project is upto my expectation
and as per the guidelines issued by CBSE

MS.DEEPTI KATARIYA MRS.SANGEETA BHARDWAJ


(P.G.T. COMPUTER SCIENCE) PRINCIPAL

3
SUPER MARKET BILLING

ACKNOWLEDGEMENT

I would like to convey my heartfelt thanks to


MS.DEEPTI KATARIYA, my Computer teacher
who always gave valuable suggestion and guidance
during the completion of this project. She has been
a source of inspiration during the completion of
my project work .She helped me to understand
and remember important details of the project
that I would have otherwise lost. My project has
been a success only because of his guidance

Name of the Student :-) HIMANSHU PUROHIT

Roll no. allotted by CBSE :-)

4
SUPER MARKET BILLING

Table of Contents
THE FEATURES OF C++ AS A LANGUAGE

OVERVIEW OF C++:-

FEATURES OF SMB

INTRODUCTION

DESIGN

HARDWARE USED

SOFTWARE USED

HEADER FILES USE IN PROJECTS

CLASS USED IN PROJECT

GLOBAL DECLARATION FOR STREAM OBJECT, OBJECT

FUNCTION TO WRITE IN FILE

FUNCTION TO READ ALL RECORDS FROM FILE

FUNCTION TO READ SPECIFIC RECORD FROM FILE

FUNCTION TO MODIFY RECORD OF FILE

FUNCTION TO DELETE RECORD OF FILE

FUNCTION TO DISPLAY ALL PRODUCTS PRICE LIST

FUNCTION TO PLACE ORDER AND GENERATING BILL FOR


PRODUCTS

5
SUPER MARKET BILLING

INTRODUCTION FUNCTION

ADMINSTRATOR MENU FUNCTION

THE MAIN FUNCTION OF PROGRAM

OUTPUT SCRRENS (SNAPSHOTS)

BIBLIOGRAPHY

6
SUPER MARKET BILLING

The Features of C++ as a Language


Now that all the necessary theory has been covered, now it is possible to
explain what C++ has to offer as a programming language. C++...

...is an open ISO-standardized language.


For a time, C++ had no official standard and was maintained by a
de-facto standard, however since 1998, C++ is standardized by a
committee of the ISO.

...is a compiled language.


C++ compiles directly to a machine's native code, allowing it to be
one of the fastest languages in the world, if optimized.
...is a strongly-typed unsafe language.
C++ is a language that expects the programmer to know what he or
she is doing, but allows for incredible amounts of control as a result.
...supports both manifest and inferred typing.
As of the latest C++ standard, C++ supports both manifest and
inferred typing, allowing flexibility and a means of avoiding verbosity
where desired.
...supports both static and dynamic type checking.
C++ allows type conversions to be checked either at compile-time or
at run-time, again offering another degree of flexibility. Most C++
type checking is, however, static.
...offers many paradigm choices.
C++ offers remarkable support for procedural, generic, and object-
oriented programming paradigms, with many other paradigms being
possible as well.
...is portable.
As one of the most frequently used languages in the world and as an
open language, C++ has a wide range of compilers that run on many
different platforms that support it. Code that exclusively uses C++'s
standard library will run on many platforms with few to no changes..
...is upwards compatible with C
C++, being a language that directly builds off C, is compatible with
almost all C code. C++ can use C libraries with few to no
modifications of the C library code.

OVERVIEW OF C++ :-

7
SUPER MARKET BILLING

C++ is a statically typed, compiled, general-purpose, case-sensitive, free-


form programming language that supports procedural, object-oriented, and
generic programming.

C++ is regarded as a middle-level language, as it comprises a


combination of both high-level and low-level language features.

C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in


Murray Hill, New Jersey, as an enhancement to the C language and
originally named C with Classes but later it was renamed C++ in 1983.

C++ is a superset of C, and that virtually any legal C program is a legal C+


+ program.

C++ Compiler:
This is actual C++ compiler, which will be used to compile your source
code into final executable program.

Most C++ compilers don't care what extension you give your source code,
but if you don't specify otherwise, many will use .cpp by default

Most frequently used and free available compiler is GNU C/C++ compiler;
otherwise you can have compilers either from HP or Solaris if you have
respective Operating Systems.

C++ Program Structure:


Let us look at a simple code that would print the words Hello World.

#include <iostream>
using namespace std;

// main() is where program execution begins.

int main()
{
cout << "Hello World"; // prints Hello World
return 0;
}

PREPROCESSOR

8
SUPER MARKET BILLING

// Comment to end of line


/* Multi-line comment */
#include <stdio.h> // Insert standard header file
#include "myfile.h" // Insert file in current directory
#define X some text // Replace X with some text
#define F(a,b) a+b // Replace F(1,2) with 1+2
#define X \
some text // Line continuation
#undef X // Remove definition
#if defined(X) // Condional compilation (#ifdef X)
#else // Optional (#ifndef X or #if !defined(X))
#endif // Required after #if, #ifdef

Comments in C++
C++ supports single line and multi-line comments. All characters available
inside any comment are ignored by C++ compiler.

C++ comments start with /* and end with */. For example:

/* This is a comment */

/* C++ comments can also


* span multiple lines
*/

A comment can also start with //, extending to the end of the line. For
example:

#include <iostream>
using namespace std;

main()
{
cout << "Hello World"; // prints Hello World

return 0;
}

C++ Primitive Built-in Types:


C++ offer the programmer a rich assortment of built-in as well as user-defined data types.
Following table list down seven basic C++ data types:

9
SUPER MARKET BILLING

Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t

Variable Definition & Initialization in C++:


Some examples are:

extern int d, f // declaration of d and f


int d = 3, f = 5; // definition and initializing d and f.
byte z = 22; // definition and initializes z.
char x = 'x'; // the variable x has the value 'x'.

C++ Variable Scope:


A scope is a region of the program and broadly speaking there are three
places where variables can be declared:

Inside a function or a block which is called local variables,


In the definition of function parameters which is called formal
parameters.
Outside of all functions which is called global variables.

C++ Constants/Literals:
Constants refer to fixed values that the program may not alter and they are
called literals.

Constants can be of any of the basic data types and can be divided in
Integer Numerals, Floating-Point Numerals, Characters, Strings and
Boolean Values.

Again, constants are treated just like regular variables except that their
values cannot be modified after their definition.

C++ Modifier Types:

10
SUPER MARKET BILLING

C++ allows the char, int, and double data types to have modifiers
preceding them. A modifier is used to alter the meaning of the base type so
that it more precisely fits the needs of various situations.

The data type modifiers are listed here:

signed
unsigned
long
short

The modifiers signed, unsigned, long, and short can be applied to


integer base types. In addition, signed and unsigned can be applied to
char, and long can be applied to double.

The modifiers signed and unsigned can also be used as prefix to long or
short modifiers. For example unsigned long int.

C++ allows a shorthand notation for declaring unsigned, short, or long


integers. You can simply use the word unsigned, short, or long, without
the int. The int is implied. For example, the following two statements both
declare unsigned integer variables.

unsigned x;
unsigned int y;

Storage Classes in C++:


A storage class defines the scope (visibility) and life time of variables
and/or functions within a C++ Program. These specifiers precede the type
that they modify. There are following storage classes which can be used in
a C++ Program

auto
register
static
extern
mutable

C++ Operators:
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. C++ is rich in built-in operators and
provides following type of operators:

Arithmetic Operators ( +, -, \, *, ++, --)

11
SUPER MARKET BILLING

Relational Operators (==, !=, >. <, >=, <=)


Logical Operators (&&, ||, ! )
Bitwise Operators (& |, ^, ~, <<, >>)
Assignment Operators (=, +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |=)
Misc Operators ( sizeof, & cast, comma, conditional etc.)

C++ Loop Types:


C++ programming language provides the following types of loops to handle looping
requirements. Click the following links to check their detail.

Loop Type Description


Repeats a statement or group of statements while a
while loop given condition is true. It tests the condition before
executing the loop body.
Execute a sequence of statements multiple times
for loop and abbreviates the code that manages the loop
variable.
Like a while statement, except that it tests the
do...while loop
condition at the end of the loop body
You can use one or more loop inside any another
nested loops
while, for or do..while loop.

C++ Decision Making:


C++ programming language provides following types of decision making statements.
Click the following links to check their detail.

Statement Description
An if statement consists of a boolean expression
if statement
followed by one or more statements.
An if statement can be followed by an optional
if...else statement else statement, which executes when the
boolean expression is false.
A switch statement allows a variable to be tested
switch statement
for equality against a list of values.
You can use one if or else if statement inside
nested if statements
another if or else if statement(s).
You can use one swicth statement inside another
nested switch statements
switch statement(s).

C++ Functions:
12
SUPER MARKET BILLING

The general form of a C++ function definition is as follows:

return_type function_name( parameter list )


{
body of the function
}

A C++ function definition consists of a function header and a function body.


Here are all the parts of a function:

Return Type: A function may return a value. The return_type is the


data type of the value the function returns. Some functions perform
the desired operations without returning a value. In this case, the
return_type is the keyword void.
Function Name: This is the actual name of the function. The
function name and the parameter list together constitute the function
signature.
Parameters: A parameter is like a placeholder. When a function is
invoked, you pass a value to the parameter. This value is referred to
as actual parameter or argument. The parameter list refers to the
type, order, and number of the parameters of a function. Parameters
are optional; that is, a function may contain no parameters.
Function Body: The function body contains a collection of
statements that define what the function does.

Numbers in C++:
Following a simple example to show few of the mathematical operations on
C++ numbers:

#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
// number definition:
short s = 10;
int i = -1000;
long l = 100000;
float f = 230.47;
double d = 200.374;

// mathematical operations;
cout << "sin(d) :" << sin(d) << endl;
cout << "abs(i) :" << abs(i) << endl;

13
SUPER MARKET BILLING

cout << "floor(d) :" << floor(d) << endl;


cout << "sqrt(f) :" << sqrt(f) << endl;
cout << "pow( d, 2) :" << pow(d, 2) << endl;

return 0;
}

C++ Arrays:
Following is an example, which will show array declaration, assignment
and accessing arrays in C++:

#include <iostream>
using namespace std;

#include <iomanip>
using std::setw;

int main ()
{
int n[ 10 ]; // n is an array of 10 integers

// initialize elements of array n to 0


for ( int i = 0; i < 10; i++ )
{
n[ i ] = i + 100; // set element at location i to i + 100
}
cout << "Element" << setw( 13 ) << "Value" << endl;

// output each array element's value


for ( int j = 0; j < 10; j++ )
{
cout << setw( 7 )<< j << setw( 13 ) << n[ j ] << endl;
}

return 0;
}

C++ Strings:
C++ provides following two types of string representations:

The C-style character string as follows:

char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};

14
SUPER MARKET BILLING

The standard C++ library provides a string class type that supports all the
operations mentioned above, additionally much more functionality.
Following is the example:

#include <iostream>
#include <string>

using namespace std;

int main ()
{
string str1 = "Hello";
string str2 = "World";
string str3;

// copy str1 into str3


str3 = str1;
cout << "str3 : " << str3 << endl;

// concatenates str1 and str2


str3 = str1 + str2;
cout << "str1 + str2 : " << str3 << endl;

return 0;
}

C++ Classes & Objects


A class definition starts with the keyword class followed by the class name;
and the class body, enclosed by a pair of curly braces. A class definition
must be followed either by a semicolon or a list of declarations. For
example we defined the Box data type using the keyword class as follows:

class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};

The keyword public determines the access attributes of the members of


the class that follow it. A public member can be accessed from outside the
class anywhere within the scope of the class object. You can also specify
the members of a class as private or protected which we will discuss in a
sub-section.

15
SUPER MARKET BILLING

Define C++ Objects:


A class provides the blueprints for objects, so basically an object is created
from a class. We declare objects of a class with exactly the same sort of
declaration that we declare variables of basic types. Following statements
declare two objects of class Box:

Box Box1; // Declare Box1 of type Box


Box Box2; // Declare Box2 of type Box

Both of the objects Box1 and Box2 will have their own copy of data
members.

Accessing the Data Members:


The public data members of objects of a class can be accessed using the
direct member access operator (.). Let us try following example to make
the things clear:

#include <iostream>

using namespace std;

class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};

int main( )
{
Box Box1; // Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box
double volume = 0.0; // Store the volume of a box here

// box 1 specification
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;

// box 2 specification
Box2.height = 10.0;
Box2.length = 12.0;
Box2.breadth = 13.0;
16
SUPER MARKET BILLING

// volume of box 1
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Volume of Box1 : " << volume <<endl;

// volume of box 2
volume = Box2.height * Box2.length * Box2.breadth;
cout << "Volume of Box2 : " << volume <<endl;
return 0;
}

C++ Inheritance:
One of the most important concepts in object-oriented programming is that
of inheritance. Inheritance allows us to define a class in terms of another
class which makes it easier to create and maintain an application. This also
provides an opportunity to reuse the code functionality and fast
implementation time.

When creating a class, instead of writing completely new data members


and member functions, the programmer can designate that the new class
should inherit the members of an existing class. This existing class is
called the base class, and the new class is referred to as the derived
class.

A class can be derived from more than one classes, which means it can
inherit data and functions from multiple base classes. To define a derived
class, we use a class derivation list to specify the base class(es). A class
derivation list names one or more base classes and has the form:

class derived-class: access-specifier base-class

Where access-specifier is one of public, protected, or private, and base-


class is the name of a previously defined class. If the access-specifier is
not used, then it is private by default.

Consider a base class Shape and its derived class Rectangle as follows:

#include <iostream>

using namespace std;

// Base class
class Shape
{

17
SUPER MARKET BILLING

public:
void setWidth(int w)
{
width = w;
}
void setHeight(int h)
{
height = h;
}
protected:
int width;
int height;
};

// Derived class
class Rectangle: public Shape
{
public:
int getArea()
{
return (width * height);
}
};

int main(void)
{
Rectangle Rect;

Rect.setWidth(5);
Rect.setHeight(7);

// Print the area of the object.


cout << "Total area: " << Rect.getArea() << endl;

return 0;
}

C++ Overloading
C++ allows you to specify more than one definition for a function name or
an operator in the same scope, which is called function overloading and
operator overloading respectively.

Following is the example where same function print() is being used to print
different data types:

18
SUPER MARKET BILLING

#include <iostream>
using namespace std;

class printData
{
public:
void print(int i) {
cout << "Printing int: " << i << endl;
}

void print(double f) {
cout << "Printing float: " << f << endl;
}

void print(char* c) {
cout << "Printing character: " << c << endl;
}
};

int main(void)
{
printData pd;

// Call print to print integer


pd.print(5);
// Call print to print float
pd.print(500.263);
// Call print to print character
pd.print("Hello C++");

return 0;
}

Polymorphism in C++
C++ polymorphism means that a call to a member function will cause a
different function to be executed depending on the type of object that
invokes the function.

Consider the following example where a base class has been derived by
other two classes and area() method has been implemented by the two
sub-classes with different implementation.

#include <iostream>
using namespace std;

19
SUPER MARKET BILLING

class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0)
{
width = a;
height = b;
}
int area()
{
cout << "Parent class area :" <<endl;
return 0;
}
};
class Rectangle: public Shape{
public:
Rectangle( int a=0, int b=0)
{
Shape(a, b);
}
int area ()
{
cout << "Rectangle class area :" <<endl;
return (width * height);
}
};
class Triangle: public Shape{
public:
Triangle( int a=0, int b=0)
{
Shape(a, b);
}
int area ()
{
cout << "Triangle class area :" <<endl;
return (width * height / 2);
}
};
// Main function for the program
int main( )
{
Shape *shape;
Rectangle rec(10,7);
Triangle tri(10,5);

20
SUPER MARKET BILLING

// store the address of Rectangle


shape = &rec;
// call rectangle area.
shape->area();

// store the address of Triangle


shape = &tri;
// call triangle area.
shape->area();

return 0;
}

Data Abstraction in C++:


Data abstraction refers to, providing only essential information to the
outside word and hiding their background details ie. to represent the
needed information in program without presenting the details.

Data abstraction is a programming (and design) technique that relies on


the separation of interface and implementation.

For example, in C++ we use classes to define our own abstract data types
(ADT). You can use the cout object of class ostream to stream data to
standard output like this:

#include <iostream>
using namespace std;

int main( )
{
cout << "Hello C++" <<endl;
return 0;
}

Here, you don't need to understand how cout displays the text on the
user's screen. You need only know the public interface and the underlying
implementation of cout is free to change.

Data Encapsulation in C++:


All C++ programs are composed of following two fundamental elements:

Program statements (code): This is the part of a program that


performs actions and they are called functions.

21
SUPER MARKET BILLING

Program data: The data is the information of the program which


affected by the program functions.

Encapsulation is an Object Oriented Programming concept that binds


together the data and functions that manipulate the data, and that keeps
both safe from outside interference and misuse. Data encapsulation led to
the important OOP concept of data hiding.

C++ supports the properties of encapsulation and data hiding through the
creation of user-defined types, called classes. We already have studied
that a class can contain private, protected and public members. By
default, all items defined in a class are private. For example:

class Box
{
public:
double getVolume(void)
{
return length * breadth * height;
}
private:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};

C++ Files and Streams:


The iostream standard library cin and cout methods for reading from
standard input and writing to standard output respectively.

To read and write from a file requires another standard C++ library called
fstream which defines three new data types:

Data Type Description


This data type represents the output file stream and
ofstream is used to create files and to write information to
files.
This data type represents the input file stream and is
ifstream
used to read information from files.
This data type represents the file stream generally,
and has the capabilities of both ofstream and
fstream
ifstream which means it can create files, write
information to files, and read information from files.

22
SUPER MARKET BILLING

Following is the C++ program, which opens a file in reading and writing
mode. After writing information inputted by the user to a file named
afile.dat, the program reads information from the file and outputs it onto the
screen:

#include <fstream>
#include <iostream>
using namespace std;

int main ()
{

char data[100];

// open a file in write mode.


ofstream outfile;
outfile.open("afile.dat");

cout << "Writing to the file" << endl;


cout << "Enter your name: ";
cin.getline(data, 100);

// write inputted data into the file.


outfile << data << endl;

cout << "Enter your age: ";


cin >> data;
cin.ignore();

// again write inputted data into the file.


outfile << data << endl;

// close the opened file.


outfile.close();

// open a file in read mode.


ifstream infile;
infile.open("afile.dat");

cout << "Reading from the file" << endl;


infile >> data;

// write the data at the screen.


cout << data << endl;

// again read the data from the file and display it.

23
SUPER MARKET BILLING

infile >> data;


cout << data << endl;

// close the opened file.


infile.close();

return 0;
}

Features of SMB
24
SUPER MARKET BILLING

SMB has some extra features as follows:

1. Easy Interface :

SMB is made of very simple interfaces. Any end user


with a minimum knowledge of operating the Computer
can easily familiar with this software

2. Automates the task :

SMB automates the task, which have to be carried out


manually in other payroll softwares. Such as it creates
Employee ID by itself, end user does not have to bother
to reminding the last employees ID and filling Employee
ID by himself.

3. Reliability :
SMB is reliable software. One can rely on the result
produced by this software. We try to remove all the
errors from it and make it Error free but it can be error
prone.

4. Compact Coding :

SMB is compact and efficient coded software. It is


developed with keeping in mind memory space and
speed. It uses less memory space and work on
increasing speed.

25
SUPER MARKET BILLING

In todays world where computers are increasingly being used in almost


all spheres of life, various types of software exist in market such as
financial accounting ,inventory control, payroll etc. Despite this
changing scenario almost all the Government organizations and
institutes are running purely using manpower only. There are some
government organizations which are fully or partially computerized.

SUPER MARKET BILLING of all ranges. The SUPER MARKET BILLING


generates billing procedure which is hectic and time consuming when
performed manually & leads to error as well.
Our project, SUPER MARKET BILLING. is a computerized
version of billing with stock maintenance.
It provides speed and reliability and helps in fast generation of
reports for evaluation and auditing purpose, keeping surplus stock,
maintaining large number of records in small magnetic store for long-
long period of time.

26
SUPER MARKET BILLING

Case Study and Raw Data

To develop a project the first necessity was to get the in-depth knowledge of C++ and also
analyze the requirement of some projects.

Features
As this project is very large, so to maintain its readability we have divided this whole

project in various functional components. This feature provides accuracy, less execution

time, error handling, and memory limitation.

Selection of language

After Analysing the main problem was to select an appropriate programming language.

We have selected C++ for developing this software because its very user friendly and

working in it is very easy

Coding
It is the actual stage where we wrote instructions in C++ to implement the Project.

27
SUPER MARKET BILLING

HARDWARE USED

Processor :- Pentium D 2.6.Ghz

Memory :- 1 GB RAM

Hard disk :- 80 GB

Monitor :- 17 Inch LG

DVD-Writer :- SONY DVD R/W

Key Board :- TVS

Mouse :- Logitech Optical

28
SUPER MARKET BILLING

SOFTWARE USED

Operating system :- Microsoft Windows Xp

Front-end :- TURBO C++

Designing Tools :- Ms-Paint

Adobe Photoshop 7.0

Documentation :- Microsoft Word 2007

29
SUPER MARKET BILLING

HOW TO INSTALL THE PROJECT AND USE IT

There are two ways to use project:-


1. Only use .exe file
2. Source code file copying in C:\ tc\bin

1. ONLY USE .EXE FILE:-


In this way we can use only .exe file.
The exe file is a file which is execute
anywhere without source code. When
we run cpp file at first time then the
c++ compiler makes .obj file and then
after solving all types of errors than
make exe file. In our project our
project exe file name is (SUPER-
~1.exe).

2. SOURCE CODE FILE COPYING IN C:\ TC\BIN:-

In this way first copy all source code


in c++ software folder. The path of c+
+ software is (C:\TC\BIN\). After
copying source code than we check
that the given source code is error-free
than we run the our project source
-code file (super-market-billing.cpp)
When we run cpp file at first time then
the c++ compiler makes SUPER-
~1.obj file and then after solving all
types of errors than make exe file. In
our project our project exe file name
is (SUPER-~1.exe).

30
SUPER MARKET BILLING

HEADER FILES USE IN PROJECTS:-

#include<conio.h>

#include<stdio.h>

#include<process.h>

#include<fstream.h>

31
SUPER MARKET BILLING

CLASS USED IN PROJECT:-

class product
{
int pno;
char name[50];
float price,qty,tax,dis;
public:
void create_product()
{
cout<<"\nPlease Enter The Product No. of The Product ";
cin>>pno;
cout<<"\n\nPlease Enter The Name of The Product ";
gets(name);
cout<<"\nPlease Enter The Price of The Product ";
cin>>price;
cout<<"\nPlease Enter The Discount (%) ";
cin>>dis;
}

void show_product()
{
cout<<"\nThe Product No. of The Product : "<<pno;
cout<<"\nThe Name of The Product : ";
puts(name);
cout<<"\nThe Price of The Product : "<<price;
cout<<"\nDiscount : "<<dis;
}

int retpno()
{return pno;}

float retprice()
{return price;}

char* retname()
{return name;}

int retdis()
{return dis;}

}; //class ends here

32
SUPER MARKET BILLING

GLOBAL DECLARATION FOR STREAM OBJECT, OBJECT:-

fstream fp;
product pr;

FUNCTION TO WRITE IN FILE:-

void write_product()
{
fp.open("Shop.dat",ios::out|ios::app);
pr.create_product();
fp.write((char*)&pr,sizeof(product));
fp.close();
cout<<"\n\nThe Product Has Been Created ";
getch();
}

FUNCTION TO READ ALL RECORDS FROM FILE:-

void display_all()
{
clrscr();
cout<<"\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n";
fp.open("Shop.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
{
pr.show_product();
cout<<"\n\n====================================\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();

33
SUPER MARKET BILLING

flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nrecord not exist";
getch();
}
FUNCTION TO MODIFY RECORD OF FILE:-

void modify_product()
{
int no,found=0;
clrscr();
cout<<"\n\n\tTo Modify ";
cout<<"\n\n\tPlease 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)
{
pr.show_product();
cout<<"\nPlease 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<<"\n\n\t Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}

FUNCTION TO DELETE RECORD OF FILE:-

void delete_product()
{
int no;
clrscr();
cout<<"\n\n\n\tDelete Record";
cout<<"\n\nPlease Enter The product no. of The Product You Want To Delete";
cin>>no;
fp.open("Shop.dat",ios::in|ios::out);

34
SUPER MARKET BILLING

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<<"\n\n\tRecord Deleted ..";
getch();
}

FUNCTION TO DISPLAY ALL PRODUCTS PRICE LIST :-

void menu()
{
clrscr();
fp.open("Shop.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN\n\n\n Go To Admin Menu to
create File";
cout<<"\n\n\n Program is closing ....";
getch();
exit(0);
}

cout<<"\n\n\t\tProduct MENU\n\n";

cout<<"====================================================\n";
cout<<"P.NO.\t\tNAME\t\tPRICE\n";

cout<<"====================================================\n";

while(fp.read((char*)&pr,sizeof(product)))
{
cout<<pr.retpno()<<"\t\t"<<pr.retname()<<"\t\t"<<pr.retprice()<<endl;
}
fp.close();
}

35
SUPER MARKET BILLING

FUNCTION TO PLACE ORDER AND GENERATING BILL FOR


PRODUCTS:-

void place_order()
{
int order_arr[50],quan[50],c=0;
float amt,damt,total=0;
char ch='Y';
menu();
cout<<"\n============================";
cout<<"\n PLACE YOUR ORDER";
cout<<"\n============================\n";
do{
cout<<"\n\nEnter The Product No. Of The Product : ";
cin>>order_arr[c];
cout<<"\nQuantity in number : ";
cin>>quan[c];
c++;
cout<<"\nDo You Want To Order Another Product ? (y/n)";
cin>>ch;
}while(ch=='y' ||ch=='Y');
cout<<"\n\nThank You For Placing The Order";getch();clrscr();

cout<<"\n\n********************************INVOICE**********************
**\n";
cout<<"\nPr No.\tPr Name\tQuantity \tPrice \tAmount \tAmount after discount\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];
damt=amt-(amt*pr.retdis()/100);

cout<<"\n"<<order_arr[x]<<"\t"<<pr.retname()<<"\t"<<quan[x]<<"\t\t"<<pr.retprice()<<
"\t"<<amt<<"\t\t"<<damt;
total+=damt;
}
fp.read((char*)&pr,sizeof(product));
}

fp.close();
}
cout<<"\n\n\t\t\t\t\tTOTAL = "<<total;
getch();
}
36
SUPER MARKET BILLING

INTRODUCTION FUNCTION :-

void intro()
{
clrscr();
gotoxy(31,11);
cout<<"SUPER MARKET";
gotoxy(35,14);
cout<<"BILLING";
gotoxy(35,17);
cout<<"PROJECT";
cout<<"\n\nMADE BY : HIMANSHU PUROHIT";
cout<<"\n\nSCHOOL : M.S.KAWAR INTERNATIONAL SCHOOL";
getch();

37
SUPER MARKET BILLING

ADMINSTRATOR MENU FUNCTION:-

void admin_menu()
{
clrscr();
char ch2;
cout<<"\n\n\n\tADMIN MENU";
cout<<"\n\n\t1.CREATE PRODUCT";
cout<<"\n\n\t2.DISPLAY ALL PRODUCTS";
cout<<"\n\n\t3.QUERY ";
cout<<"\n\n\t4.MODIFY PRODUCT";
cout<<"\n\n\t5.DELETE PRODUCT";
cout<<"\n\n\t6.VIEW PRODUCT MENU";
cout<<"\n\n\t7.BACK TO MAIN MENU";
cout<<"\n\n\tPlease Enter Your Choice (1-7) ";
ch2=getche();
switch(ch2)
{
case '1': clrscr();
write_product();
break;
case '2': display_all();break;
case '3':
int num;
clrscr();
cout<<"\n\n\tPlease 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();
}
}

38
SUPER MARKET BILLING

THE MAIN FUNCTION OF PROGRAM:-

void main()
{
char ch;
intro();
do
{
clrscr();
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t01. CUSTOMER";
cout<<"\n\n\t02. ADMINISTRATOR";
cout<<"\n\n\t03. EXIT";
cout<<"\n\n\tPlease 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');
}

//***************************************************************
END OF PROJECT
//***************************************************************

39
SUPER MARKET BILLING

40
SUPER MARKET BILLING

41
SUPER MARKET BILLING

42
SUPER MARKET BILLING

43
SUPER MARKET BILLING

44
SUPER MARKET BILLING

THE END OUTPUT SCREENS

45
SUPER MARKET BILLING

1. WWW.GOOGLE.COM
2. WWW.1000PROJECTS.COM
3. Problem Solving with C++ - The Object of
Programming by Walter Savitch,
Fifth Edition, Addison-Wesley Pub.
4. Beginning C++ Game Programming by
Michael Dawson, Second Edition,
Cengage Learning Pub.

46
SUPER MARKET BILLING

47

Vous aimerez peut-être aussi