Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 20
struct car {
char *Plate ;
char *Brand;
char *Model;
char *Color;
int ProductionYear;
int Price;
char *Status;
};
int Adding_a_new_car(Car *galleryPtr);
int Update_the_information_of_the_selected_car(Car *galleryPtr);
int Renting_a_car(Car *galleryPtr);
int Taking_back_a_car(Car *galleryPtr);
int Searching_an_available_car(Car *galleryPtr);
char* plate[SIZE] ={"TR1234A","TR4558A","TR7895A","TR7895A","TR1236A","TR1228A","TR2589A","TR2134A","TR2574A","TR4782A"};
char* brand[SIZE] = {"Toyota","Toyota","Opel","Ferrari","Renault","Fiat","Ford","Opel","Fiat","Ford"};
char* model[SIZE] = {"Verso","Anversis","Corsa","Anvensis","Clio","Vectra","Corsa","Corsa","Vectra","Corsa"};
char* color[SIZE] = {"Green","Gray","Blue","Red","White","Blue","Red","Green","Gray","White"};
int carYear[SIZE] = {"2004","2005","2002","2003","2005","2008","2009","2001","2004","2005"};
int carPrice[SIZE] = {"60000","70000","30000","40000","70000","30000","60000","80000","10000","90000"};
char* status[SIZE] = {"available","rented","available","available","rented","available","available","rented","rented","available"};
typedef struct car Car;
int main(int argc, char *argv[])
{
Car gallery[20];
char plate[20];
char brand[20];
char model[20];
char color[20]
int productionyear;
int price;
char status[20];
int selection = 0;
while(selection != 5)
{
print_menu();
scanf("%d", &selection);
switch(selection)
{
case 1:
Adding_a_new_car(gallery);
break;
case 2:
Update_the_information_of_the_selected_car(gallery);
break;
case 3:
Renting_a_car(gallery);
break;
case 4:
Taking_back_a_car(gallery);
break;
case 5:
Searching_an_available_car(gallery);
break;
}
}
system("PAUSE");
return 0;
}
int Adding_a_new_car(gallery)
{
printf("\t%-10s%s", "Plate", ":");
scanf("%s", plate);
printf("\t%-10s%s","Brand", ":");
scanf("%s", brand);
printf("\t%-10s%s","Model", ":");
scanf("%s", model);
printf("\t%-10s%s","Color", ":");
scanf("%s", color);
printf("\t%-10s%s","Production Year", ":");
scanf("%d", &carYear);
printf("\t%-10s%s","Price", ":");
scanf("%d", &carPrice);
printf("\t%-10s%s","Status", ":");
scanf("%s", status);
gallery.Plate = plate;
gallery.Brand = brand;
gallery.Model = model;
gallery.Color = color;
gallery.ProductionYear = carYear;
gallery.Price = carPrice;
gallery.Status = status;
printf("\n\n----| car Info |----\n\n");
printf("%10s: %s\n","Plate", gallery.Plate);
printf("%10s: %s\n", "Brand", gallery.Brand);
printf("%10s: %d\n", "Model", gallery.Model);
printf("%10s: %d\n", "Color", gallery.Color );
printf("%10s: %s\n", "ProductionYear", gallery.ProductionYear);
printf("%10s: %s\n","Price", gallery.Price);
printf("%10s: %s\n","Status", gallery.Status);
system("PAUSE");
}
int Update_the_information_of_the_selected_car(gallery)
{
int i;
printf("enter the plate of the car : %s", plate);
scanf("%s", &plate)
for (i = 0; i<19 ; i++){
result = strncmp( plate, plate[i], 20);
if(result == 0)
{
printf("\t%-10s%s","enter the new brand", ":");
scanf("%s", brand);
printf("\t%-10s%s","enter the new model", ":");
scanf("%d", model);
printf("\t%-10s%s","enter the new color", ":");
scanf("%d", color);
printf("\t%-10s%s","enter the new production year", ":");
scanf("%s", &carYear);
printf("\t%-10s%s","enter the new price", ":");
scanf("%d", &carPrice);
printf("\t%-10s%s","enter the new status", ":");
scanf("%d", status);
Car.Brand = brand;
Car.Model = model;
Car.Color = color;
Car.ProductionYear = carYear;
Car.Price = carPrice;
Car.Status = status;
printf("\n\n----| car's new Info |----\n\n");
printf("%10s: %s\n","Plate", Car.Plate);
printf("%10s: %s\n", "Brand", Car.Brand);
printf("%10s: %d\n", "Model", Car.Model);
printf("%10s: %d\n", "Color", Car.Color );
printf("%10s: %s\n", "ProductionYear", Car.ProductionYear);
printf("%10s: %s\n","Price", Car.Price);
printf("%10s: %s\n","Status", Car.Status);
}
else {
printf("\n Sorry , the car with plate : %s has not been found\n\n",plate);
}
system ("PAUSE");
}
int Renting_a_car()
{
printf("enter the plate of the car : %s", plate);
scanf("%s", plate)
for (i = 0; i<9 ; i++){
result = strncmp( plate, plate[i], 20);
if(result == 0)
{
printf("\t%-10s%s","enter the new status", ":");
scanf("%d", status);
Car.Status = status;
printf("%10s: %s\n","Status", Car.Status);
}
else {
printf ("\n sorry the plate %s u have entered is wrong.\n\n",plate);
}
system ("PAUSE");
}
int Taking_back_a_car()
{
printf("enter the plate of the car : %s", plate);
scanf("%s", plate)
for (i = 0; i<9 ; i++){
result = strncmp( plate, plate[i], 20);
if(result == 0)
{
printf("\t%-10s%s","enter the status \"available\" ", ":");
scanf("%d", status);
Car.Status = status;
printf("%10s: %s\n","Status", Car.Status);
}
else {
printf ("\n sorry the plate %s u have entered is wrong.\n\n",plate);
}
}
int Searching_an_available_car()
{
}
int print_menu()
{
system("CLS");
printf("--- Car gallary management ---\n\n");
printf("\n%d.Adding a new car\n",1);
printf("----------------\n");
printf("\n%d.Updating the information of the selected car\n",2);
printf("----------------\n");
printf("\n%d.Renting a car \n",3);
printf("----------------\n");
printf("\n%d.Taking back a car \n",4);
printf("----------------\n");
printf("\n%d.Searching an available car \n",5);
printf("----------------\n");
printf("\n Your selection \n");
return 0;
}
it wont compile at all.