gAdIs90 0 Newbie Poster
#include <stdio.h>
#include <string.h>


struct mycar
{
 char plate[10];
 int ey,em,ed,eh,emin,qy,qm,qd,qh,qmin,wd,parked;

 };

struct mycar car[2];
int n;
void main()
{
    void input();
    void display();
    int menu();
    void exit();
    int op;
    n=0;

    printf(">>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
    printf(">>>>\tCAR PARK SYSTEM MANAGEMENT SYSTEM \t<<<<");
    printf("\n\n>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
    for(;;)
    {
        op=menu();
        //printf("op=%d");
        if(op==0)break;
        switch(op)
        {

        case 1: input();break;
        case 2: exit();break;
        case 3: display();break;
   } //switch
  } //for
 }
int menu()
{

    int option;

    printf("\n\n\t1. New Car\n");
    printf("\t2. Exit\n");
    printf("\t3. Display\n");
    printf("\t0. Quit program\n");
    printf("\n\n\n\t\tEnter your option: ");
    scanf("%d",&option);
    printf("\n\n>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");

    return(option);

 }
void exit()
{
    char temp[10];
    int hour,min,diff,i,j,found=0;

    printf("\nEnter plate No.:\n ");
    scanf("%s",temp);

    for(i=0;i<n;i++)
        if(strcmp(car[i].plate,temp)==0)
       {
           found=1;j=i;
        }
        if(found==1)
        {
            printf("\nEnter date and time for exit(dd mm yyyy hh mm):\n");
            scanf("%d %d %d %d %d",&car[j].qd,&car[j].qm,&car[j].qy,&car[j].qh,&car[j].qmin);
            car[n].parked=0;
            //write your statements to calculate the bill
            //same day calculation

            hour=car[j].qh-car[j].eh;
            min=car[j].qmin-car[j].emin;

            //printf("hour=%d min=%d\n",hour,min);
            diff=hour*60+min;
            printf("\n\nTotal min. parked=%d\n",&diff);
        }
        else
            printf("Sorry Plate No. not found...\n");
}
void input()
{
  if(n<2)
  {
      printf("\nEnter plate No.: ");
      scanf("%s",car[n].plate);

      printf("\nEnter date and time(dd mm yyyy hh mm):");
      scanf("%d %d %d %d %d",&car[n].ed,&car[n].em,&car[n].ey,&car[n].eh,&car[n].emin);
      car[n].parked=1;
      n++;
  }
  else
      printf("Sorry, parking lot is full\n");
}
void display()
{
    int i;
    printf("\n\t%10s  %3s  %3s  %4s  %2s  %3s\n\n","Plate No.","Day","Mon","Year","Hour","Minute");

    for(i=0;i<n;i++)
    {
        printf("\t%10s  %3d  %3d  %4d  %2d    %3d",car[i].plate,car[i].ed,car[i].em,car[i].ey,car[i].eh,car[i].emin,car[i].parked);

    }
    printf("\n\nTotal No. of cars=%d\n",n);
 }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.