Sie sind auf Seite 1von 38

COMPUTER PROJECT

VEHICLE MANAGEMENT

SUBMITTED BY
PRATYAKSH JAIN
15CSE50
MDU
ACKNOWLEDGEMENT
It is my pleasure to place on record my deep sense
of gratitude to our respected computer teacher Mrs Neha
Sehrawat for their deep interest, support and guidance
throughout the course of this project work. I am indebted to
parents for the inspiration and help given to me to do this
project. My thanks are due to my classmates for helping us to
make our project a better one. Above all, I thank God for
enabling me to do this project work and come out victorious.
CONTENTS
1. OVERVIEW OF C++

2. NEED FOR PROJECT

3. SYSTEM REQUIREMENTS

4. HOW TO INSTALL AND RUN

5. HEADER FILES

6. CLASSES, FUNCTIONS & OBJECTS

7. SOURCE CODE

8. SAMPLE OUTPUT

9. CONCLUISION

10. BIBLIOGRAPHY

OVERVIEW OF C++
Programming language provides various ways of
specifying programs for computer to work. Unlike natural
language programming languages are designed to permit no
ambiguity and to be concise. C++ is a general purpose
programming language. C++ is regarded as a mid level
language, as it comprises a combination of both high level
and low level language features. It is a statically typed, free-
form, multi-paradigm, usually compiled language supporting
procedural programming, data abstraction, oop’s, generic
programming.
The C++ programming was developed at AT & T Bell
laboratories.
In the early 1980’s by Bjarane Stroustrup. He founded ‘C’
lacking for simultaneous and decided to extend the language
by adding features from his favourite language, simula 67.
Simula 67 was one of the earliest object oriented languages.
The name C++ was coined by Rick Mascitti where “++” is the
C increment operator. Ever since its birth C++ evolved to cope
up with problems encountered by users and through
discussion at AT & T. However the maturation of the C++
language is attested to buy two recent events.
1. Formation of ANSI(American National Standard
Institute) C++ committee.
2. The publication of the annotated C++ reference
manual by Ellis and Stroustrup.
C++ provides a predefined set of data types for handling
the data to users. The data can either be fundamental or
derived. The derived data types in C++ comes in two groups,
built in types and user defined types. Data can be stored in
any of these data types.
C++ introduces some object-oriented features to see. It
offers classes, which provide four features commonly, present
in object-oriented languages: abstraction, encapsulation,
inheritance and polymorphism.
C++ is very rich in operators. In fact C++ places more
significance on operators than most other computer
languages do. C++ offers different classes of operators:
arithmetic,relational,logical,increment/decrement,
conditional, bit wise etc. In addition C++ has some special
operators for particular tasks. Each operator performs a
specific task it is designed for.

NEED FOR PROJECT/SUMMARY


In this fast growing world vehicles have become a part
and parcel of our life. The management of vehicles is also a
necessary thing as compared to the user.
All the details about vehicles cannot be stored in paper
and this creates a need for computers to store the details.
Our project is created in such way that helps the user to do
the complete management of the vehicles such as (has the
vehicle been caught in an accident if so what type of an
accident small, big, medium. It also helps in finding the fine
rate of the vehicle, it also helps to find the rent to be paid if
the vehicles are taken on lease depending on the number of
days which is taken for etc). This project also includes some
basic facts of C++ such as files, inheritance, classes, functions
and structures.

SYSTEM REQUIREMENTS
HARDWARE

PROCESSOR PENTIUM 4 OR HIGHER


RAM 256 MB OR HIGHER

MONITOR 17 INCH COLOUR MONITOR


KEYBOARD 104 KEYBOARD
MOUSE STANDARD MOUSE

SOFTWARE

OPERATING SYSTEM WINDOWS XP OR HIGHER

PROGRAM TURBO C++ COMPILER

HOW TO INSTALL AND RUN


 INSTALL C++ IN C:\TCC
 COPY THE SOURCE CODE FILE IN C:\TCC
 THEN GOTO START AND SELECT TURBO C++
 SELECT FILE AND OPEN THE SOURCE CODE FILE
FROM C:\TCC
 CLICK ON COMPILE BUTTON TO COMPILE THE
PROGRAM
 CLICK ON RUN BUTTON TO RUN THE PROGRAM

HEADER FILES
 iostream.h-----The header file declares the basic C++
streams I/O routines
 conio.h-----The commonly used function clrscr ( ) that
clears the output screen is included in this header file.
 string.h----The header file declares several string
manipulations memory manipulation routines like
strcmp( ) (function used for comparing two strings).
 fstream.h----The header file used for doing the various
file handling operations

CLASSES, FUNCTIONS & OBJECTS


CLASS
 CAR----TO STORE THE DETAILS OF CAR
 MOTORBIKE----TO STORE THE DETAILS OF MOTORBIKE
 JCB----TO STORE THE DETAILS OF JCB
 BUS----TO STORE THE DETAILS OF BUS
 VAN----TO STORE THE DETAILS OF VAN
 HEAVY----TO STORE THE DETAILS OF HEAVY
VEHICLES(JCB,BUS,VAN)

OBJECTS
 CA----OBJECT FOR CALLING CAR
 MOTO----OBJECT FOR CALLING MOTORBIKE
 U[10]----TO STORE THE NUMBER OF CAR
 V[10]----TO STORE THE NUMBER OF MOTORBIKE
 W[10]----TO STORE THE NUMBER OF HEAVY VEHICLE

FUNCTIONS
 READC----TO READ CAR INFORMATION
 DISPLAYC----TO DISPLAY CAR INFORMATION
 CALCFINEC----TO DO THE CALCULATIONS ABOUT CAR
 TOTALCOSTC----TO CALCULATE THE TOTAL COST OF
RENTED CARS
 READB----TO READ MOTORBIKE INFORMATION
 CALCFINEB----TO DO THE CALCULATIONS ABOUT
MOTORBIKE
 TOTALCOSTB----TO CALCULATE THE TOTAL COST OF
RENTED MOTORBIKE
 DISPLAYB----TO DISPLAY MOTORBIKE INFORMATION
 READJCB----TO READ THE DETAILS OF JCB
 DISPLAYJCB----TO DISPLAY THE DETAILS OF JCB
 READBUS----TO READ THE DETAILS OF BUS
 DISPLAYBUS----TO DISPLAY THE DETAILS OF BUS
 READVAN----TO READ THE VALUES OF VAN
 DISPLAYVAN----TO DISPLAY THE DETAILS OF VAN
 READH----FOR HEAVY VEHICLE DATA ENTRY
 TOTALCOSTH----TO CALCULATE TOTAL COST OF RENTED
HEAVY VEHICLES
 DISPLAYH----TO DISPLAY THE DETAILS OF RENTED HEAVY
VEHICLES

SOURCE CODE
/*

***********************VEHICLE**DATA**MANAGEMENT**SYSTEM****************
**********

*/

#include<iostream.h>

#include<fstream.h>

#include<string.h> //For strcmp ()

#include<conio.h> //For clrscr ()

#include<stdio.h>
/*

********************************STRUCTURE**EXPENSES***********************
**********

*/

struct expense

float petrol_cost;

float maintenance_cost;

float government_tax;

};

/*

*********************************CLASS***CAR*******************************
**********

*/

class car

public:

char accident_gradec;

char car_type[20];

char companyc[20];

char name_c[20];

float car_cost;

int car_number;

int number_of_daysc;

float total_costc;

float finec;

void readc();
void displayc();

void totalcostc();

void calcfinec();

};

/*

**********************************car**function**one*************************
*********

*/

void car::readc()

cout<<"\n"<<"CAR DATA READING";

char c='n';

cout<<"\n"<<"Enter the borrowers name:";

cin.ignore();

cin.getline(name_c,20);

cin.ignore();

cout<<"\n"<<"Enter the car company:";

cin.getline(companyc,20);

cout<<"\n"<<"Enter the car number:";

cin>>car_number;

cout<<"\n"<<"Enter the number of days on rent:";

cin>>number_of_daysc;

cout<<"\n"<<"Enter the car type (FR,MR,FF,4WD):";

//function for reading car data

cin>>car_type;

cout<<"\n"<<"Enter the car cost:";

cin>>car_cost;
cout<<"\n"<<"Has an accident been involved? (y/n):";

cin>>c;

if(c=='y'||c=='Y')

calcfinec();

else

accident_gradec='o';

finec=0.0;

cout<<"\n"<<"CAR DATA READING ENDED"<<"\n";

/*

********************car**function**two**********************/

void car::calcfinec()

cout<<"\n"<<"CAR FINE BEING CALCULATED";

cout<<"\n"<<"Enter the accident grade(s- small accident)(m- medium accident)(b- big


accident):";

cin>>accident_gradec;

float d;

if(strcmp(companyc,"ferrari")==0)

d=10;

else if(strcmp(companyc,"toyota")==0)

d=9;

else if(strcmp(companyc,"honda")==0)

d=8;

else if(strcmp(companyc,"ford")==0)
//Function to calculate car fine

d=7;

else if(strcmp(companyc,"dodge")==0)

d=6;

else if(strcmp(companyc,"mitsubishi")==0)

d=5;

else if(strcmp(companyc,"skoda")==0)

d=4;

else if(strcmp(companyc,"maruti")==0)

d=3;

else if(strcmp(companyc,"ambassador")==0)

d=2;

//Fine=carcostx(accidentgrade/100)xcompany value

else

d=1;

float e;

if((accident_gradec=='s')||(accident_gradec=='S'))

e=3;

else if((accident_gradec=='m')||(accident_gradec=='M'))

e=5;

else if((accident_gradec=='b')||(accident_gradec=='B'))

e=8;
}

else

e=1;

finec=float(car_cost*(e/100)*d);

cout<<"\n"<<"CAR FINE CALCULATED"<<"\n";

/*

******************************car**function**three***************************
**********

*/

void car::totalcostc()

cout<<"\n"<<"TOTAL COST FOR CAR BEING CALCULATED";

//Function to calculate car totalcost

total_costc=(1000*number_of_daysc)+finec;

cout<<"\n"<<"TOTAL COST CALCULATED"<<"\n";

/*

*****************************car**function**four*****************************
**********

*/

void car::displayc()

cout<<"\n\t\t"<<"DISPLAYING CAR DATA";

cout<<"\n"<<"Name of the borrower of the car:";

puts(name_c);

cout<<"\n"<<"Number of days rented:"<<number_of_daysc;


cout<<"\n"<<"Cost of borrowed car:"<<car_cost;

cout<<"\n"<<"Car number is:"<<car_number;

cout<<"\n"<<"The car company is:";

puts(companyc);

cout<<"\n"<<"The car type is:"<<car_type;

if(accident_gradec=='o')

cout<<"\n"<<"The borrower was not involved in any accident"; //Function to display car
details

cout<<"\n"<<"fine=0";

else

cout<<"\n"<<"THE BORROWER WAS INVOLVED IN AN ACCIDENT";

cout<<"\n"<<"THE FINE IS:"<<finec<<"Rupees";

cout<<"\n"<<"The total cost is:"<<total_costc<<"Rupees";

cout<<"\n"<<"END OF CAR DATA DISPLAY"<<"\n";

/*

**********************************Class**Motorbike**************************
**********

*/

class motorbike

public:

char accident_gradeb;

char companyb[20];

char name_b[20];
int powerb;

double bike_cost;

int bike_number;

int number_of_daysb;

double total_costb;

double fineb;

void readb();

void displayb();

void totalcostb();

void calcfineb();

};

/*

*****************************motorbike**function**one************************
*********

*/

void motorbike::readb()

cout<<"MOTORBIKE DATA READING";

char c='n';

cin.ignore();

cout<<"\n"<<"Enter the borrowers name:";

cin.getline(name_b,20);

cout<<"\n"<<"Enter the motorbike company:";

cin.getline(companyb,20);

cout<<"\n"<<"Enter the motorbike number:";

cin>>bike_number;
cout<<"\n"<<"Enter the number of days on rent:";

cin>>number_of_daysb;

cout<<"\n"<<"Enter the Motorbike power (cc):";

cin>>powerb;

cout<<"\n"<<"Enter the motorbike cost:";

cin>>bike_cost;

cout<<"\n"<<"Has an accident been involved? (y/n):";

cin>>c;

if(c=='y'||c=='Y')

calcfineb();

else

accident_gradeb='o';

fineb=0;

cout<<"\n"<<"MOTORBIKE DATA READING ENDED"<<"\n";

/*

*****************************motorbike**function**two************************
*********

*/

void motorbike::calcfineb()

cout<<"\n"<<"MOTORBIKE FINE BEING CALCULATED";

cout<<"\n"<<"Enter the accident grade(s- small accident)(m- medium accident)(b- big


accident):";

cin>>accident_gradeb;
int d;

if(strcmp(companyb,"Harley davidson")==0)

d=10;

else if(strcmp(companyb,"hayabuza")==0)

d=9;

else if(strcmp(companyb,"honda")==0)

d=8;

else if(strcmp(companyb,"suzuki")==0)

d=7;

else if(strcmp(companyb,"red bull")==0)

d=6;

else if(strcmp(companyb,"mitsubishi")==0)

//Function to calculate car fine

d=5;

else if(strcmp(companyb,"lotus")==0)

d=4;

else if(strcmp(companyb,"pulsar")==0)

d=3;

else if(strcmp(companyb,"scooter")==0)

d=2;

//Fine=bikecostx(accidentgrade/100)xcompany value

else

d=1;

int e;

if((accident_gradeb=='s')||(accident_gradeb=='S'))

e=3;
}

else if((accident_gradeb=='m')||(accident_gradeb=='M'))

e=5;

else if((accident_gradeb=='b')||(accident_gradeb=='B'))

e=8;

else

e=1;

fineb=double(bike_cost*(e/100)*d);

cout<<"\n"<<"MOTORBIKE FINE CALCULATED"<<"\n";

/*

****************************motorbike**function**three***********************
***********/

void motorbike::totalcostb()

cout<<"\n"<<"TOTAL COST FOR MOTORBIKE BEING CALCULATED";

//Function to calculate motorbike totalcost

total_costb=500*number_of_daysb+fineb;

cout<<"\n"<<"TOTAL COST CALCULATED"<<"\n";

/*

****************************motorbike**function**four************************
**********
*/

void motorbike::displayb()

cout<<"\n"<<"DISPLAYING MOTORBIKE DATA";

cout<<"\n"<<"Name of the borrower of the Motorbike:";

puts(name_b);

cout<<"\n"<<"Number of days rented:"<<number_of_daysb;

cout<<"\n"<<"Cost of borrowed motorbike:"<<bike_cost;

cout<<"\n"<<"Motorbike number is:"<<bike_number;

cout<<"\n"<<"The motorbike company is:";

puts(companyb);

cout<<"\n"<<"The motorbike power is:"<<powerb<<" cc";

//Function to display motorbike data

if(accident_gradeb=='o')

cout<<"\n"<<"The borrower was not involved in any accident"; //Function to display car
details

cout<<"\n"<<"fine=0";

else

cout<<"\n"<<"THE BORROWER WAS INVOLVED IN AN ACCIDENT";

cout<<"\n"<<"THE FINE IS:"<<fineb<<"Rupees";

cout<<"\n"<<"The total cost is:"<<total_costb<<"Rupees";

cout<<"\n"<<"END OF MOTORBIKE DATA DISPLAY"<<"\n";

/*
*******************************BASE**CLASS**JCB****************************
**********

*/

class JCB

public:

int no_of_jcb;

int no_of_daysjcb;

void readjcb()

cout<<"\n"<<"Enter the number of JCB's Rented:";

cin>>no_of_jcb;

cout<<"\n"<<"Enter the number of days rented:";

cin>>no_of_daysjcb;

cout<<"\n";

void displayjcb()

cout<<"\n"<<"The number of JCB’s rented is:"<<"\n"<<no_of_jcb;

cout<<"\n"<<"The number of days rented is:"<<"\n"<<no_of_daysjcb;

};

/*

********************************BASE**CLASS**BUS***************************
**********

*/

class BUS

public:
int no_of_bus;

int no_of_daysbus;

void readbus()

cout<<"\n"<<"Enter the number of Buses Rented:";

cin>>no_of_bus;

cout<<"\n"<<"Enter the number of days rented:";

cin>>no_of_daysbus;

cout<<"\n";

void displaybus()

cout<<"\n"<<"The number of Buses rented is:"<<"\n"<<no_of_bus;

cout<<"\n"<<"The number of days rented is:"<<"\n"<<no_of_daysbus;

};

/*

*******************************BASE**CLASS**VAN***************************
**********

*/

class VAN

public:

int no_of_van;

int no_of_daysvan;

void readvan()

cout<<"\n"<<"Enter the number of Vans Rented:";

cin>>no_of_van;
cout<<"\n"<<"Enter the number of days rented:";

cin>>no_of_daysvan;

cout<<"\n";

void displayvan()

cout<<"\n"<<"The number of Vans rented is:"<<"\n"<<no_of_van;

cout<<"\n"<<"The number of days rented is:"<<"\n"<<no_of_daysvan;

cout<<"\n";

};

/*

*****************************DERIVED**CLASS**HEAVY*************************
*********

*/

class heavy: public JCB, public BUS, public VAN

public:

char name_of_borrowerh[20];

double total_costh;

void readh();

void totalcosth();

void displayh();

};

/*

******************************heavy**function**one**************************
**********

*/

void heavy::readh()
{

cout<<"\n"<<"ENTERING THE HEAVY VEHICLE DATA";

cout<<"\n"<<"Enter the name of the heavy vehicle borrower:";

cin.getline(name_of_borrowerh,20);

readjcb();

readbus();

readvan();

totalcosth();

cout<<"\n"<<"END OF HEAVY VEHICLE DATA ENTRY"<<"\n";

/*

**********************************heavy**function**two**********************
**********

*/

void heavy::totalcosth()

cout<<"\n"<<"CALCULATING HEAVY VEHICLE TOTALCOST";

total_costh=(no_of_jcb*no_of_daysjcb*435.5)+

( no_of_bus*no_of_daysbus*350.5)+

( no_of_van*no_of_daysvan*300.2);

cout<<"\n"<<"TOTAL COST CALCULATED"<<"\n";

/*

********************************heavy**function**three***********************
**********

*/

void heavy::displayh()

cout<<"\n"<<"DISPLAYING HEAVY VEHICLE DATA";


cout<<"\n"<<"The name of the borrower of the heavy vehicle is:";

puts(name_of_borrowerh);

cout<<"\n"<<"The total cost is:"<<total_costh<<" Rupees";

displayjcb();

displaybus();

displayvan();

cout<<"\n"<<"END OF HEAVY VEHICLE DISPLAY"<<"\n";

/*

**********************************Main**Function****************************
**********

*/

int main()

clrscr();

car ca;

motorbike moto;

//Variable declaration

int i,j,k;

int L,m,n;

float t1=0,t2=0,t3=0,tot=0;

float total_expenses;

char abc;

cout<<"\t\t\t"<<"WELCOME TO THE VEHICLE DATA MANAGEMENT SYSTEM";

ofstream fout1;

fout1.open("accc.txt",ios::out|ios::app);

cout<<"\n"<<"How many car records must be entered:"<<"\a";

cin>>i;
cout<<"\n"<<"How many motorbike records must be entered:"<<"\a";

cin>>j;

cout<<"\n"<<"How many heavy vehicle records must be entered:"<<"\a";

cin>>k;

car u[10];

motorbike v[10];

heavy w[10];

L=i;

m=j;

n=k;

fout1.seekp(0);

for(i=0;i<L;i++)

//Loop to process car rental data

abc='n';

u[i].readc();

u[i].totalcostc();

t1=t1+u[i].total_costc;

getch();

cout<<"\n"<<"Do you want to see the entered car data? (y/n):";

cin>>abc;

if(abc=='y'||abc=='Y')

u[i].displayc();

fout1<<"\n\t\t"<<"DISPLAYING CAR DATA";

fout1<<"\n"<<"Name of the borrower of the car:";

fout1<<u[i].name_c;
fout1<<"\n"<<"Number of days rented:"<<u[i].number_of_daysc;

fout1<<"\n"<<"Cost of borrowed car:"<<u[i].car_cost;

fout1<<"\n"<<"Car number is:"<<u[i].car_number;

fout1<<"\n"<<"The car company is:";

fout1<<u[i].companyc;

fout1<<"\n"<<"The car type is:"<<u[i].car_type;

if(u[i].accident_gradec=='o')

fout1<<"\n"<<"The borrower was not involved in any accident"; //Function to display car
details

fout1<<"\n"<<"fine=0";

else

fout1<<"\n"<<"THE BORROWER WAS INVOLVED IN AN ACCIDENT";

fout1<<"\n"<<"THE FINE IS:"<<u[i].finec<<" Rupees";

fout1<<"\n"<<"The total cost is:"<<u[i].total_costc<<"Rupees";

fout1<<"\nThe total profit on car rent:"<<t1<<"Rupees\n";

fout1.close();

ofstream fout2;

fout2.open("accb.txt",ios::out|ios::app);

for(j=0;j<m;j++)

//Loop to process motorbike rental data

abc='n';

v[j].readb();
v[j].totalcostb();

t2=t2+v[j].total_costb;

cout<<"\nDo you want to see the entered motorbike data(y/n):";

cin>>abc;

if(abc=='y'||abc=='Y')

v[j].displayb();

fout2<<"\n"<<"DISPLAYING MOTORBIKE DATA";

fout2<<"\n"<<"Name of the borrower of the Motorbike:";

fout2<<v[j].name_b;

fout2<<"\n"<<"Number of days rented:"<<v[j].number_of_daysb;

fout2<<"\n"<<"Cost of borrowed motorbike:"<<v[j].bike_cost;

fout2<<"\n"<<"Motorbike number is:"<<v[j].bike_number;

fout2<<"\n"<<"The motorbike company is:";

fout2<<v[j].companyb;

fout2<<"\n"<<"The motorbike power is:"<<v[j].powerb<<" cc";

//Function to display motorbike data

if(v[j].accident_gradeb=='o')

fout2<<"\n"<<"The borrower was not involved in any accident"; //Function to display car
details

fout2<<"\n"<<"fine=0";

else

fout2<<"\n"<<"THE BORROWER WAS INVOLVED IN AN ACCIDENT";

fout2<<"\n"<<"THE FINE IS:"<<v[j].fineb<<"Rupees";


}

fout2<<"\n"<<"The total cost is:"<<v[j].total_costb<<"Rupees";

fout2<<"\nThe total profit on motorbike rent: "<<t2<<"Rupees\n";

fout2.close();

for(k=0;k<n;k++)

//Loop to process heavy vehicle rental data

abc='n';

w[k].readh();

t3=t3+w[k].total_costh;

cout<<"\nDo you want to see the entered heavy vehicle data(y/n):";

cin>>abc;

if(abc=='y'||abc=='Y')

w[k].displayh();

cout<<"\nThe total profit on heavyvehicle rent:"<<t3<<"Rupees\n";

expense exp;

cout<<"\nENTER THE MONTHLY EXPENSES DATA";

//Entering the business expenses

cout<<"\nEnter the petrol/diesel cost:";

cin>>exp.petrol_cost;

cout<<"\nEnter the maintenance cost:";

cin>>exp.maintenance_cost;
cout<<"\nEnter the government taxloss:";

cin>>exp.government_tax;

tot=t1+t2+t3-(exp.petrol_cost+exp.maintenance_cost+exp.government_tax);

cout<<"\n\aTHE CURRENT MONTHLY PROFIT:"<<tot<<"Rupees\n";

abc='n';

cout<<"\nDo you wish to see the accident records(y/n):";

cin>>abc;

if(abc=='y'||abc=='Y')

ifstream fin1;

fin1.open("accc.txt",ios::in);

fin1.seekg(0);

while(fin1)

fin1.read((char*)&ca,sizeof(ca));

ca.displayc();

fin1.close();

cout<<"\nAll car accident Records Displayed"<<endl;

ifstream fin2;

fin2.open("accb.txt",ios::in);

fin2.seekg(0);

while(fin2)

fin2.read((char*)&moto,sizeof(moto));

moto.displayb();

fin2.close();
cout<<"\nAll motorbike accident Records Displayed"<<endl;

cout<<"\n\nEND OF PROGRAM";

getch();

return(0);

//END OF PROGRAM

/*

***************************************************************************
**********

*/

}
OUTPUT SCREEN
CONCLUSION
This project is created in such a way that helps the
user to do the complete management of rented vehicles such
as calculating the fine rate of the vehicle, it also helps to find
the rent to be paid if the vehicles are taken on lease
depending on the number of days which is taken for. It
calculates the total rent to be paid by the lender. It also
calculates the profit made by the vehicle owner.
BIBLIOGRAPHY
THIS PROJECT IS DONE BY REFERING
 CLASS XII TEXTBOOK
 WIKIPEDIA
 GOOGLE
 AND OTHER INTERNET SOURCES.

Das könnte Ihnen auch gefallen