Parking Project Using If and Else Statement in C++ |C++ Programming

Parking Project Using If and Else Statement in C++ |C++ Programming.

Parking Project:

This is the Parking project in C++. In this project, I will simply use If and else statement in C++.
Actually, parking is a place which is used to park different vehicles. 
The vehicles include:
  • Cars
  • Buses
  • rickshaws
  • Cycles 
  • Moter cycles
  • and many more
    Parking Project Using If and Else Statement in C++ |C++ Programming
    Parking Project Using If and Else Statement in C++ |C++ Programming
    .

if and else statement in c++

Now how to use if and else state meant in c++. if and else statement is used when we have more than one condition. Then we tell the program which one you should choose using if and else statement.
Then the program decided which one condition will be better.

Parking Project Description:

In this C++ project, we will take the data of cars, buses, rickshaws, cycles, and motorcycles. And we will charge the bus car for 100 rupees, buses for 300 rupees, rickshaws for 200 rupees, cycles for 30 rupees, motorcycles for 50 rupees.

Now The Code for This Program:

/*
#include<iostream>
using namespace std;
int main()
{
//here are the globel variables
int input = 0, amount = 0, count = 0, rik = 0, bus = 0, car = 0, cycles = 0, motorcycles = 0;
//loop to repeat the programe
while (input < 100 && input != 8)
{
//menu of the programe
cout << "please press 1 for rikshaw entry and the fees will be Rs.100:" << endl;
cout << "please press 2 for bus entry and the fees will be Rs.300:" << endl;
cout << "please press 3 for car entry and the fees will be Rs.200:" << endl;
cout << "please press 4 for cycles entry and the fees will be Rs.30:" << endl;
cout << "please press 5 for motorcycles entry and the fees will be Rs,50:" << endl;
cout << "please press 6 for to show the records:" << endl;
cout << "please press 7 to delete the records:" << endl;
cout << "please press 8 to excit the programes:" << endl;
//input from users
cin >> input;
//for input 1
if (input == 1)
{
//conditions to check the numbers of vehicles
if (input < 100)
{
amount = amount + 100;
rik++;
count++;
cout << "*************************************" << endl;
cout << "your Data is Saved successully" << endl;
cout << "*************************************" << endl;
}
else
{
//if the parking is full
cout << "Sorry !!!The parking is full now ";
cout << endl;
cout << endl;
}
}
else if (input == 2)
{
//conditions to check the numbers of vehicles
if (input < 100)
{
amount = amount + 300;
bus++;
count++;
cout << "*************************************" << endl;
cout << "your Data is Saved successully" << endl;
cout << "*************************************" << endl;
}
else
{
//if the parking is full
cout << "Sorry !!!The parking is full now ";
cout << endl;
cout << endl;
}
}
else if (input == 3)
{
//conditions to check the numbers of vehicles
if (input < 100)
{
amount = amount + 200;
car++;
count++;
cout << "*************************************" << endl;
cout << "your Data is Saved successully" << endl;
cout << "*************************************" << endl;
}
else
{
//if the parking is full
cout << "Sorry !!!The parking is full now ";
cout << endl;
cout << endl;
}
}
else if (input == 4)
{
//conditions to check the numbers of vehicles
if (input < 100)
{
amount = amount + 30;
cycles++;
count++;
cout << "*************************************" << endl;
cout << "your Data is Saved successully" << endl;
cout << "*************************************" << endl;
}
else
{
//if the parking is full
cout << "Sorry !!!The parking is full now ";
cout << endl;
cout << endl;
}
}
else if (input == 5)
{
//conditions to check the numbers of vehicles
if (input < 100)
{
amount = amount + 50;
motorcycles++;
count++;
cout << "*************************************" << endl;
cout << "your Data is Saved successully" << endl;
cout << "*************************************" << endl;
}
else
{
//if the parking is full
cout << "Sorry !!!The parking is full now ";
cout << endl;
cout << endl;
}
}
else if (input == 6)
{
//to get the full information
cout << "*****************************************" << endl;
cout << "the total amount in Rs=" << amount << endl;
cout << "the total number of vehicle(s) =" << count << endl;
cout << "the total number of Rickshaw(s) =" << rik << endl;
cout << "the total number of bus(s) =" << bus << endl;
cout << "the total number of car(s) =" << car << endl;
cout << "the total number of cycles(s) =" << cycles << endl;
cout << "the total number of motorcycles(s) =" << motorcycles << endl;
cout << "*****************************************" << endl;
cout << endl;
cout << endl;
}
else if (input == 7)
{
//to delete the data
count = 0;
rik = 0;
bus = 0;
amount = 0;
car = 0;
motorcycles = 0;
cycles = 0;
cout << "*****************************************" << endl;
cout << "The data is deleted successfully" << endl;
cout << "*****************************************" << endl;
cout << "the total number(s) of vehicle(s)=" << count << endl;
cout << "the total number(s) of cars(s)=" << car << endl;
cout << "the total number(s) of bus(s)=" << bus << endl;
cout << "the total number(s) of rickshaw(s)=" << rik << endl;
cout << "the total number(s) of cycles(s)=" << cycles << endl;
cout << "the total number(s) of motorcycles(s)=" << motorcycles << endl;
cout << "*****************************************" << endl;
cout << endl;
cout << endl;
}
else if (input == 8)
{
cout << "*****************************************" << endl;
cout << "Y0u excited from the Programe!!!!!" << endl;
cout << "*****************************************" << endl;
cout << endl;
cout << endl;
}
else
{
cout << "*****************************************" << endl;
cout << "Oh!!!!!!you entered the wrong input" << endl;
cout << "*****************************************" << endl;
cout << endl;
cout << endl;
}
}
system("pause");
return 0;
}
*/

Conclusion:

So we can conclude that if and else condition is very simple to see and we can make lots of projects using if and else conditions in C++.

Suggestions:

If you have a suggestion regarding this project then please tell me about this in the comment box. Thanks with the Best regards Bilal Ahmad.

1 comment:

Please tell me if you have any suggestions related to these projects.
thanks

Powered by Blogger.