Cars Showroom
Project using C++
As we
all know that programming knowledge has given a immense change in the technology
of world. With the help of programming knowledge lots of new and innovative
things are made to be possible. No doubt for expertise in programming knowledge
needs some time but after doing daily practice on it we can expertise on any
programming knowledge very quickly. In the student level we learn the syntax of
programming languages and try to make some project related to real life using
this programming languages. Today we are going to make the Cars showroom
project using C++ language.
About Cars
Showroom Project
Cars
Showroom Project is related to real life. For example in real life we want to
buy any car so we can go to the cars showroom and there we see different-2
types of cars and choose according to our comfort. Same in the Cars Showroom Project
we have made one online showroom where the user have to choose the car from the
following different cars. But before that the customer eagerly want to know the
specification of the car he going to purchase. So we have made system that when
customer chooses his car then we have to show the car specification to customer.
Now Let implement the code so you can well understood about the cars showroom
project.
Source
Code for Cars Showroom Project
#include<iostream>
using namespace std;
class car
{
protected:
string cars_model;
int mileage;
string fuel_type;
int fuel_tank_capacity;
int price;
int warranty;
int insurance_expenses;
};
class audi:public car
{
public:
audi()
{
cars_model = "Audi A6";
mileage = 14;
fuel_type = "Petrol";
fuel_tank_capacity = 73;
price = 60.81;
warranty= 2;
insurance_expenses = 31350;
}
void display()
{
cout<<"Cars Model = "<<cars_model<<endl;
cout<<"Mileage = "<<mileage<<"km/litre"<<endl;
cout<<"Fuel Type = "<<fuel_type<<endl;
cout<<"Fuel Tank Capacity = "<<fuel_tank_capacity<<"litres"<<endl;
cout<<"Price = "<<price<<"lakhs"<<endl;
cout<<"Warranty = "<<warranty<<"years"<<endl;
cout<<"Insurance Expenses = "<<insurance_expenses<<"Rs."<<endl;
}
};
class ford:public car
{
public:
ford()
{
cars_model = "Ford Endeavour";
mileage = 14;
fuel_type = "Diesel";
fuel_tank_capacity = 80;
price = 30.25;
warranty= 3;
insurance_expenses = 96288;
}
void display()
{
cout<<"Cars Model = "<<cars_model<<endl;
cout<<"Mileage = "<<mileage<<"km/litre"<<endl;
cout<<"Fuel Type = "<<fuel_type<<endl;
cout<<"Fuel Tank Capacity = "<<fuel_tank_capacity<<"litres"<<endl;
cout<<"Price = "<<price<<"lakhs"<<endl;
cout<<"Warranty = "<<warranty<<"years"<<endl;
cout<<"Insurance Expenses = "<<insurance_expenses<<"Rs."<<endl;
}
};
class BMW: public car
{
public:
BMW()
{
cars_model = "BMW X5";
mileage = 13;
fuel_type = "Petrol/Diesel";
fuel_tank_capacity = 83;
price = 80.63;
warranty= 3;
insurance_expenses = 51350;
}
void display()
{
cout<<"Cars Model = "<<cars_model<<endl;
cout<<"Mileage = "<<mileage<<"km/litre"<<endl;
cout<<"Fuel Type = "<<fuel_type<<endl;
cout<<"Fuel Tank Capacity = "<<fuel_tank_capacity<<"litres"<<endl;
cout<<"Price = "<<price<<"lakhs"<<endl;
cout<<"Warranty = "<<warranty<<"years"<<endl;
cout<<"Insurance Expenses = "<<insurance_expenses<<"Rs."<<endl;
}
};
class maruti_suzuki:public car
{
public:
maruti_suzuki()
{
cars_model = "Maruti XL6";
mileage = 18;
fuel_type = "Petrol";
fuel_tank_capacity = 45;
price = 10.70;
warranty= 2;
insurance_expenses = 46000;
}
void display()
{
cout<<"Cars Model = "<<cars_model<<endl;
cout<<"Mileage = "<<mileage<<"km/litre"<<endl;
cout<<"Fuel Type = "<<fuel_type<<endl;
cout<<"Fuel Tank Capacity = "<<fuel_tank_capacity<<endl;
cout<<"Price = "<<price<<"lakhs"<<endl;
cout<<"Warranty = "<<warranty<<"years"<<endl;
cout<<"Insurance Expenses = "<<insurance_expenses<<"Rs."<<endl;
}
};
int main()
{
int c;
cout<<"welcome to the cars showroom choose the car you want"<<endl;
cout<<"1.Audi"<<endl;
cout<<"2.Ford"<<endl;
cout<<"3.BMW"<<endl;
cout<<"4.Maruti Suzuki"<<endl;
cin>>c;
switch(c)
{
case 1:
{
audi a;
a.display();
break;
}
case 2:
{
ford f;
f.display();
break;
}
case 3:
{
BMW b;
b.display();
break;
}
case 4:
{
maruti_suzuki m;
m.display();
break;
}
}
}
Output of Cars Showroom Project :
Explanation
of source code is given below :
We have made
the cars showroom project with the help of some OOP[ object oriented Programming]
concept like Classes and object and one of the main feature of OOP that is
inheritance. The key points of making the cars showroom project.
1. We have used the classes and object concept for our cars showroom
project.
2. After that we have declare the car parts as a variable in the class car.
3. After declaring car parts we have inherit the cars parts in the
different classes using the concept of inheritance. Because all the car have
some necessary parts like wheels , fuel type, mileage, insurance expenses , cars
warranty.
4. At last we have using switch statement so we can show different-2 cars
model as per customer choices.
Comments
Post a Comment