Your job is to write a C program that implements a simple car rental information
ID: 3915616 • Letter: Y
Question
Your job is to write a C program that implements a simple car rental information system. Your program keeps track of the cars of a rental company and rental information. The program provides a simple user interface to add cars to the company's inventory, to make a car reservation, find a reservation, print rented and non-rented vehicles, and compute average number of days rented. Your program must use the data types and variables described below. A type definition of a new structure named Car to store car information. This structure must have the following fields int carId; // a unique ID of a car char make [20]; // make of the car char mode1[20]model of the car int numDoors; // 2 or 4 door cars double rate; II the rental rate of the car A type definition of a new structure named Rental to store rental information of a renter: char renterName[201; I/ name of renter int daysRenting; // days renting the car int carId; // ID of the car rented Two arrays in main0 function that store car information and rental information: Car allCars[20]; I/ a list of cars Rental allRentals [60]; /7 a list of rentalsExplanation / Answer
#include <stdio.h>
#include <string.h>
struct Cars
{
int carId;
char make[20];
char model[20];
int numDoors;
double rate;
};
struct Rental
{
char renterMame[20];
int daysRanting;
int carId;
};
int createInventory(struct Cars *allCars);
int main()
{
int i,totalCars,totalRentals,tempcars;
struct Cars allCars[20];
struct Rental allrentals[60];
tempcars=createInventory(allCars);
totalCars=tempcars;
printf("first car is %d",allCars[0].carId);
return 0;
}
int createInventory(struct Cars *allCars)
{
int i;
for(i=0;i<2;i++)
{
printf(" Enter Car Id : ");
scanf("%d",&allCars[i].carId);
printf(" Enter Car Makers : ");
scanf("%s",&allCars[i].make);
printf(" Enter Car model : ");
scanf("%s",&allCars[i].model);
printf(" Enter Car's no of Doors : ");
scanf("%d",&allCars[i].numDoors);
printf(" Enter Car's rate : ");
scanf("%lf",&allCars[i].rate);
}
return i;
}
if you have any query please ask me in the commnet .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.