car park management system source code
#1

Pls show the source code for car park management system project...
Reply
#2

car park management system source code



#include <stdio.h>
#include <conio.h>
#include <windows.h>

#define CAR 1
#define SCOOTER 2

/* to store vehicle number, and its
row-col position in an array */
struct vehicle
{
int num ;
int row ;
int col ;
int type ;
} ;

int parkinfo[4][10] ; /* a 2-D array to store number of vehicle parked */
int vehcount ; /* to store total count of vehicles */
int carcount ; /* stores total count of cars */
int scootercount ; /* stores total count of scooters */

void display( ) ;
void changecol ( struct vehicle * ) ;
struct vehicle * add ( int, int, int, int ) ;
void del ( struct vehicle * ) ;
void getfreerowcol ( int, int * ) ;
void getrcbyinfo ( int, int, int * ) ;
void show( ) ;

/* decrements the col. number by one
this fun. is called when the data is
shifted one place to left */
void changecol ( struct vehicle *v )
{
v -> col = v -> col - 1 ;
}

/* adds a data of vehicle */
struct vehicle * add ( int t, int num, int row, int col )
{
struct vehicle *v ;

v = ( struct vehicle * ) malloc ( sizeof ( struct vehicle ) ) ;

v -> type = t ;
v -> row = row ;
v -> col = col ;

if ( t == CAR )
carcount++ ;
else
scootercount++ ;

vehcount++ ;
parkinfo[row][col] = num ;

return v ;
}

/* deletes the data of the specified
car from the array, if found */
void del ( struct vehicle *v )
{
int c ;

for ( c = v -> col ; c < 9 ; c++ )
parkinfo[v -> row][c] = parkinfo[v -> row][c+1] ;

parkinfo[v -> row][c] = 0 ;

if ( v -> type == CAR )
carcount-- ;
else
scootercount-- ;

vehcount-- ;
}

/* get the row-col position for the vehicle to be parked */
void getfreerowcol ( int type, int *arr )
{
int r, c, fromrow = 0, torow = 2 ;

if ( type == SCOOTER )
{
fromrow += 2 ;
torow += 2 ;
}

for ( r = fromrow ; r < torow ; r++ )
{
for ( c = 0 ; c < 10 ; c++ )
{
if ( parkinfo[r][c] == 0 )
{
arr[0] = r ;
arr[1] = c ;
return ;
}
}
}

if ( r == 2 || r == 4 )
{
arr[0] = -1 ;
arr[1] = -1 ;
}
}

/* get the row-col position for the vehicle with specified number */
void getrcbyinfo ( int type, int num, int *arr )
{
int r, c, fromrow = 0, torow = 2 ;

if ( type == SCOOTER )
{
fromrow += 2 ;
torow += 2 ;
}

for ( r = fromrow ; r < torow ; r++ )
{
for ( c = 0 ; c < 10 ; c++ )
{
if ( parkinfo[r][c] == num )
{
arr[0] = r ;
arr[1] = c ;
return ;
}
}
}

if ( r == 2 || r == 4 )
{
arr[0] = -1 ;
arr[1] = -1 ;
}
}

/* displays list of vehicles parked */
void display( )
{
int r, c ;

printf ( "Cars ->\n" ) ;

for ( r = 0 ; r < 4 ; r++ )
{
if ( r == 2 )
printf ( "Scooters ->\n" ) ;

for ( c = 0 ; c < 10 ; c++ )
printf ( "%d\t", parkinfo[r][c] ) ;
printf ( "\n" ) ;
}
}

int main( )
{
int choice, type, number, row = 0, col = 0 ;
int i, tarr[2] ;
int finish = 1 ;

/* creates a 2-D array of car and scooter class */
struct vehicle *car[2][10] ;
struct vehicle *scooter[2][10] ;

system ( "cls" ) ;

/* displays menu and calls corresponding functions */
while ( finish )
{
system ( "cls" ) ;

printf ( "\nCar Parking\n" ) ;
printf ( "1. Arrival of a vehicle\n" ) ;
printf ( "2. Total no. of vehicles parked\n" ) ;
printf ( "3. Total no. of cars parked\n" ) ;
printf ( "4. Total no. of scooters parked\n" ) ;
printf ( "5. Display order in which vehicles are parked\n" ) ;
printf ( "6. Departure of vehicle\n" ) ;
printf ( "7. Exit\n" ) ;
scanf ( "%d", &choice ) ;

switch ( choice )
{
case 1 :
system ( "cls" ) ;
printf ( "\nAdd: \n" ) ;

type = 0 ;

/* check for vehicle type */
while ( type != CAR && type != SCOOTER )
{
printf ( "Enter vehicle type (1 for Car / 2 for Scooter ): \n" ) ;
scanf ( "%d", &type ) ;
if ( type != CAR && type != SCOOTER )
printf ( "\nInvalid vehicle type.\n" ) ;
}

printf ( "Enter vehicle number: " ) ;
scanf ( "%d", &number ) ;

/* add cars' data */
if ( type == CAR || type == SCOOTER )
{
getfreerowcol ( type, tarr ) ;

if ( tarr[0] != -1 && tarr[1] != -1 )
{
row = tarr[0] ;
col = tarr[1] ;

if ( type == CAR )
car[row][col] = add ( type, number, row, col ) ;
else
scooter[row - 2][col] = add ( type, number, row, col ) ; ;
}
else
{
if ( type == CAR )
printf ( "\nNo parking slot free to park a car\n" ) ;
else
printf ( "\nNo parking slot free to park a scooter\n" ) ;
}
}
else
{
printf ( "Invalid type\n" ) ;
break ;
}

printf ( "\nPress any key to continue..." ) ;
getch( ) ;
break ;

case 2 :
system ( "cls" ) ;
printf ( "Total vehicles parked: %d\n", vehcount ) ;
printf ( "\nPress any key to continue..." ) ;
getch( ) ;
break ;

case 3 :
system ( "cls" ) ;
printf ( "Total cars parked: %d\n", carcount ) ;
printf ( "\nPress any key to continue..." ) ;
getch( ) ;
break ;

case 4 :
system ( "cls" ) ;
printf ( "Total scooters parked: %d\n", scootercount ) ;
printf ( "\nPress any key to continue..." ) ;
getch( ) ;
break ;

case 5 :
system ( "cls" ) ;
printf ( "Display\n" ) ;
display( ) ;
printf ( "\nPress any key to continue..." ) ;
getch( ) ;
break ;

case 6 :
system ( "cls" ) ;
printf ( "Departure\n" ) ;
type = 0 ;
/* check for vehicle type */
while ( type != CAR && type != SCOOTER )
{
printf ( "Enter vehicle type (1 for Car / 2 for Scooter ): \n" ) ;
scanf ( "%d", &type ) ;
if ( type != CAR && type != SCOOTER )
printf ( "\nInvalid vehicle type.\n" ) ;
}
printf ( "Enter number: " ) ;
scanf ( "%d", &number ) ;

if ( type == CAR || type == SCOOTER )
{
getrcbyinfo ( type, number, tarr ) ;
if ( tarr[0] != -1 && tarr[1] != -1 )
{
col = tarr [1] ;
/* if the vehicle is car */
if ( type == CAR )
{
row = tarr [0] ;
del ( car [row][col] ) ;
for ( i = col ; i < 9 ; i++ )
{
car[row][i] = car[row][i + 1] ;
changecol ( car[row][i] ) ;
}
free ( car[row][i] ) ;
car[row][i] = NULL ;
}
/* if a vehicle is scooter */
else
{
row = tarr[0] - 2 ;
if ( ! ( row < 0 ) )
{
del ( scooter[row][col] ) ;
for ( i = col ; i < 9 ; i++ )
{
scooter[row][i] = scooter[row][i + 1] ;
changecol ( scooter[row][col] ) ;
}
scooter[row][i] = NULL ;
}
}
}
else
{
if ( type == CAR )
printf ( "\nInvalid car number, or a car with such number has not been parked here.\n" ) ;
else
printf ( "\nInvalid scooter number, or a scooter with such number has not been parked here.\n" ) ;
}
}
printf ( "\nPress any key to continue..." ) ;
getch( ) ;
break ;

case 7 :
system ( "cls" ) ;
for ( row = 0 ; row < 2 ; row++ )
{
for ( col = 0 ; col < 10 ; col++ )
{
if ( car[row][col] -> num != 0 )
free ( car[row][col] ) ;
if ( scooter[row][col] -> num != 0 )
free ( scooter[row+2][col] ) ;
}
}
finish = 0 ;
break ;
}
}
return 0 ;
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: university park golf course in, hostal del seminario, park engineering hawaii, mp sangra id num, car rent management system ppt, analysis of mansfield park, linkin park collision course tracklist,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  srs on textile management system 2 2,454 25-12-2018, 08:03 PM
Last Post: Selva lakshmi
  dfd for alumni management system 1 2,835 23-09-2018, 12:00 PM
Last Post: Guest
  free download source code of online college magazine 5 17,865 29-06-2018, 10:09 AM
Last Post: Guest
  opengl source code for butterfly 3 3,267 14-05-2018, 08:57 AM
Last Post: Akshatha k
  program code of solar tracking system using 8051 microcontroller 6 23,366 03-05-2018, 09:30 PM
Last Post: Guest
  ice cream parlour management system in vb source code 4 5,290 04-04-2018, 11:58 PM
Last Post: vprk77
  source code in php for online training and placement cell management 1 6,688 23-03-2018, 09:06 AM
Last Post: ritzi
  free download college website project in html with source code 2 4,622 24-02-2018, 10:46 AM
Last Post: Guest
  citizen card system full code download 2 4,770 19-02-2018, 02:30 PM
Last Post: [email protected]
  online shopping management system project pdf 1 3,875 14-02-2018, 02:55 PM
Last Post: jai kumar maurya

Forum Jump: