0% found this document useful (0 votes)
162 views6 pages

Bike Parking Project (Coding)

This document contains the code for a C++ program that implements a computerized bike parking system. The program allows users to enter a password to access the system functionality, which includes bike entry, viewing parking status, displaying bike owners, and bike exit. It uses functions like ifstream, ofstream and fstream to read from and write to an external text file for data storage. The code demonstrates the basic logic and flow for a bike parking management system.

Uploaded by

Information 4U
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views6 pages

Bike Parking Project (Coding)

This document contains the code for a C++ program that implements a computerized bike parking system. The program allows users to enter a password to access the system functionality, which includes bike entry, viewing parking status, displaying bike owners, and bike exit. It uses functions like ifstream, ofstream and fstream to read from and write to an external text file for data storage. The code demonstrates the basic logic and flow for a bike parking management system.

Uploaded by

Information 4U
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIVERSITY OF NAROWAL

DEPARTMENT OF CS & IT

Project :
Computerized Bike
Parking System
Submitted TO :
Sir Adnan Waheed
Group Name :
CS-Thunder
Group Members :
1. Ahsan Raza(0006-BS-CS-
2019)
2. Shawaz ul Rehman(0022-
BS-CS-2019)
3. M. Nafees ur Rahman
(0017-BS-CS-2019)
UNIVERSITY OF NAROWAL
DEPARTMENT OF CS & IT

Coding :
#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;
void main()
{

int i = 3, x, j, SpaceForBikes = 100;


string ParkingPassword = "CS-Thunder";
string password;

int t = 1;
string ownername;
string bikenumber;
string cnic;

int NumberOfBikes = 0;
cout << "\n" << endl;
cout << "\n";
cout << " " << setw(50) <<
"===========================================================" << endl;
cout << setw(4) << "||" << setw(46) << "
" << setw(6) << "||" << endl;
cout << setw(4) << "||" << "\tWelcome To Computerized Motorcycle Parking System"
<< setw(4) << "||" << endl;
cout << setw(4) << "||" << setw(46) << "
" << setw(6) << "||" << endl;
cout << " " << setw(50) <<
"===========================================================" << endl;
cout << "\n\n\n" << endl;
cout << "Rules of Bike Parking : " << endl;
cout << "------------------------------------------------------------------------"
<< endl;
cout << "1. Firstly Enter a Parking Password." << endl;

cout << "2. After Entered Password You Must Enter Your Personal Information." <<
endl;
cout << "3. Every Bike Owner get a Token Number." << endl;
cout << "4. When You Exit from Parking; You Enter a Token Number for Exiting."
<< endl;
cout << "------------------------------------------------------------------------"
<< endl;
cout << endl;
cout << "Enter Password : " << endl;
UNIVERSITY OF NAROWAL
DEPARTMENT OF CS & IT

cin >> password;


cout << endl;
if (password != ParkingPassword)
{
while (i > 0)
{
cout << "Your Password is incorrect." << endl;
cout << "You have " << i << " tries left." << endl;
cout << "Enter Password : " << endl;
cin >> password;
i--;
if (password == ParkingPassword)
goto loop;

}
}
loop:while (password == ParkingPassword)
{

cout << "=========================================================" << endl;


cout << "\n1. Bike Enter\n2. Parking Status";
cout << "\n3. Display Bikes Owners\n4. Bike Exit From Parking";
cout << "\n5. For Delete Data ";
cout << "\nFor Exiting Press Any Other Key";
cout << endl;
cout << "=========================================================" << endl;
cout << "\nSelect" << endl;
cin >> j;
cout << endl;
if (j == 1)
{

cout << "Your Token Number is : " << endl;


cin >> t;

cout << "Enter Bike Number : (ABC-0000-YY)" << endl;


cin >> bikenumber;
cout << "Enter Owner Name : " << endl;
cin >> ownername;
cout << "Enter Owner CNIC Number : (eg. 34602-4536967-3)" << endl;
cin >> cnic;

NumberOfBikes = NumberOfBikes + 1;
SpaceForBikes = SpaceForBikes - 1;
ofstream file;

file.open("parking.txt", ios::app);

file << t;
file << endl;
file << bikenumber;
file << endl;
UNIVERSITY OF NAROWAL
DEPARTMENT OF CS & IT

file << ownername;


file << endl;

file.close();
goto loop;
}
else if (j == 2)
{
cout << "Number of Bikes = " << NumberOfBikes << endl;
cout << "\nSpace for Bikes is : " << SpaceForBikes << endl;
goto loop;
}
else if (j == 3)
{
ifstream disdata;
disdata.open("parking.txt");
disdata >> t;
disdata >> bikenumber;
disdata >> ownername;

while (!disdata.eof())
{

cout << "\nToken Number : " << t;


cout << "\nBike Number is : " << bikenumber;
cout << "\nOwner Name is : " << ownername;
cout << endl;

disdata >> t;
disdata >> bikenumber;
disdata >> ownername;

}
disdata.close();
goto loop;

}
else if (j == 4)
{
cout << "\nEnter Token Number for Exit : " << endl;
cin >> x;
ifstream del;
del.open("parking.txt");
ofstream n;
n.open("new.txt");
del >> t;
del >> bikenumber;
del >> ownername;

while (!del.eof())
{
UNIVERSITY OF NAROWAL
DEPARTMENT OF CS & IT

if (t != x)
{

n << t;
n << endl;
n << bikenumber;
n << endl;
n << ownername;
n << endl;

}
else
{
cout << "Bike Exit Successfully!" << endl;
}
del >> t;
del >> bikenumber;
del >> ownername;

}
n.close();
del.close();
if (remove("parking.txt") != 0)
{
cout << "\nFile does not remove" << endl;
}
else
{
cout << "\nOK" << endl;
}
if (rename("new.txt", "parking.txt") != 0)
{
cout << "\nFile does not rename" << endl;
}
else
{
cout << "\nOK" << endl;
}
NumberOfBikes = NumberOfBikes - 1;
SpaceForBikes = SpaceForBikes + 1;
goto loop;
}

else if (j == 5)
{
ifstream file;
if (remove("parking.txt") != 0)
{
cout << "\nFile does not remove" << endl;
}
else
{
UNIVERSITY OF NAROWAL
DEPARTMENT OF CS & IT

cout << "\nOK" << endl;


}
NumberOfBikes = NumberOfBikes * 0;
SpaceForBikes = 100;
goto loop;
}
else
{
break;
}

}
system("pause");
}

You might also like