Question


Car Rental Management System The aim of this project is to design and implement a computerized Car Rental Management System for a company called COEN244Cars. The company rents two types of cars: standard and luxury cars. A car is identified by a car identification number (int), a type (string), and a flag that indicates whether the car is currently available or not. The company distinguishes between three types of customers: regular customers, corporate customers, and VIPs (Very Important Persons). A customer is identified by a customer number (int, name (string), address (string), and a telephone number (string). A corporate customer has the following additional attributes: The name (string) and address of the customers company (string). Furthermore, the customers have different types of privileges. A regular customer can only rent standard cars for a maximum period of 20 days. Corporate customers and VIPs can rent all types of cars. However, corporate customers can rent a car for a maximum period of 345 days, whereas VIPs can rent a car for a maximum period of 45 days Using your system, the COEN244Car company should be able to do the following tasks a) Add a new car to the inventory b) Remove an existing car from the inventory c) Register new customers d) Remove a given customer from the customers list e) Rent a car to a customer f) Return a car and update car information g) Return the privileges of a particular customer h) Change the privileges (e.g., modify the rental period for regular customers to 25) i) Determine whether a given car is rented or not j) Determine whether a given customer has rented a car k) Determine whether a given car is a regular customer, corporate, or VIP l) Determine the types of cars rented by a customer of a given company Question 1 (80 marks) A. Implement the class or classes that represent the car information. B. Implement the class or classes that represent the companys customers. C. Implement the class CarRentalManagement that supports the functions (a) to (I) Notes: Provide all the necessary data members, constructors, copy constructors, destructors, and member functions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note:

1. The point k in the requirements has some error, as a car can not be a customer, so it has been assumed that the requirement is to tell the type of the customer which has rented a particular car.

2. Only the address fields have been considered to be containing spaces, rest of the input values must not have spaces.

Code to Copy:

//Remove the stdafx.h header file

//if not using visual studio.

#include "stdafx.h"

//Include the required

//header files.

#include <iostream>

#include <string>

//Use the standard namespace.

using namespace std;

//Define the

//class Car.

class Car

{

//Declare the

//required variables.

string type;

int id_no;

int avail;

//Define the required

//public members.

public:

//Define the

//default constructor.

Car()

{

int x;

cout << "Enter the type of the car" << endl

<< "1.Standard"

<< endl << "2.Luxury" << endl;

cin >> x;

while (x < 1 || x>2)

{

cout << "Please enter a valid choice(1/2): " << endl;

cin >> x;

}

if (x == 1)

{

type = "Standard";

}

else

{

type = "Luxury";

}

cout << "Enter the id_no of the car: ";

cin >> id_no;

avail = 1;

}

string get_type()

{

return type;

}

int get_id()

{

return id_no;

}

//Define the

//method() get_avail().

int get_avail()

{

return avail;

}

void set_avail(int x)

{

avail = x;

}

};

//Define the class Customer.

class Customer

{

//Declare the

//required private members.

int cno;

string name;

string address;

string tel_no;

string cust_type;

int days;

int rent;

int r_car_id;

//Define the required

//public members.

public:

Customer()

{

}

//Define the parametrized constructor.

Customer(string temp_cust_type)

{

cout << "Enter the customer number: ";

cin >> cno;

cout << "Enter the address of the customer: ";

getline(cin, address);

cin.ignore(256, '\n');

cout << "Enter the tel_no of the customer: ";

cin >> tel_no;

cust_type = temp_cust_type;

days = 0;

rent = 0;

r_car_id = -1;

}

//Define the getter functions.

int get_cno()

{

return cno;

}

void set_rent_id(int z)

{

r_car_id = z;

}

int get_rent_id()

{

return r_car_id;

}

void set_rent(int x)

{

rent = x;

}

void set_days(int y)

{

days = y;

}

int get_rent()

{

return rent;

}

string get_type()

{

return cust_type;

}

//Define a virtual function cname()

// to be used in corporate

//class only.

virtual string getcname()

{

return "nothing";

}

};

//Define the class

//representing regular customers.

class reg_customer :public Customer

{

public:

reg_customer() :Customer("Regular")

{

}

};

//Define the class

//representing corporate customers.

class cor_cust :public Customer

{

string c_name;

string c_address;

public:

cor_cust() :Customer("Corporate")

{

cout << "Enter the name of the customer's company: ";

cin >> c_name;

cout << "Enter the address of the customer's company: ";

getline(cin, c_address);

cin.ignore(256, '\n');

}

string getcname()

{

return c_name;

}

};

//Define the class

//representing VIP customers.

class vip_customer :public Customer

{

public:

vip_customer() :Customer("VIP")

{

}

};

//Define the class CarRentalManagement.

class CarRentalManagement

{

//Define tan array

//of pointers of

//the Car class.

Car *inventory[100];

//Decalare a variable to store

//the total number of cars

//in the inventory.

int no_cars;

//Define an array of pointers

//of Customer type so that any

//type of customer can be

//stored in it.

Customer *list[100];

//Declare the variable to store

//the total number of customers

//in the list.

int no_cust;

//Declare the variable to store

//the privilleges of different

//types of customers.

int reg_days;

int cor_days;

int vip_days;

public:

CarRentalManagement()

{

no_cars = 0;

no_cust = 0;

reg_days = 25;

cor_days = 35;

vip_days = 45;

//Initialize the pointers

//to NULL to avoid memory

//access violations.

for (int i = 0; i < 100; i++)

{

inventory[i] = NULL;

list[i] = NULL;

}

}

void display()

{

char ch;

cout << endl << "Please choose one of the following options:\n" << endl;

cout << "a) Add a new car to the inventory"

<< endl << "b) Remove an existing car from the inventory"

<< endl << "c) Register new customers"

<< endl << "d) Remove a given customer from the customer's list"

<< endl << "e) Rent a car to a customer"

<< endl << "f) Return a car and update car information"

<< endl << "g) Return the privileges of a particular customer"

<< endl << "h) Change the privileges"

<< endl << "i) Determine whether a given car is rented or not "

<< endl << "j) Determine whether a given customer has rented a car"

<< endl << "k) Determine whether a given car is"

<< " a rented by a regular customer, corporate, or VIP "

<< endl << "l) Determine the types of cars"

<< " rented by a customer of a given company";

cout << endl << "m) Exit" << endl;

cin >> ch;

process_choice(ch);

}

void process_choice(char ch)

{

switch (ch)

{

case 'a':

inventory[no_cars++] = new Car();

break;

case 'b':

remove_car();

break;

case 'c':

add_customer();

break;

case 'd':

rem_cust();

break;

case 'e':

rent_car();

break;

case 'f':

int cid;

cout << "Enter the id of the customer: ";

cin >> cid;

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_cno() == cid)

{

if (list[i]->get_rent() == 1)

{

list[i]->set_rent(0);

}

else

{

cout << "This customer has not rented car.";

break;

}

for (int k = 0; k<no_cars; k++)

{

if (inventory[k]->get_id() == list[i]->get_rent_id())

{

inventory[k]->set_avail(1);

break;

}

}

list[i]->set_rent_id(0);

break;

}

}

break;

case 'g':

int x;

cout << "Enter the id of the customer: ";

cin >> x;

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_cno() == x)

{

privileges(list[i]->get_type());

break;

}

}

break;

case 'h':

change_priveleges();

break;

case 'i':

check_car();

break;

case 'j':

check_cust();

break;

case 'k':

find_car();

break;

case 'l':

find_comp();

break;

case 'm':

cout << "Now Exiting..." << endl;

return;

default:

cout << "Please enter a valid choice." << endl;

}

display();

}

void find_comp()

{

string comp;

cout << "Enter the name of the company to be checked: ";

cin >> comp;

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_type() == "Corporate")

{

if (list[i]->getcname() == comp && list[i]->get_rent() == 1)

{

for (int k = 0; k<no_cars; k++)

{

if (inventory[k]->get_id() == list[i]->get_rent_id())

{

cout << inventory[k]->get_type() << endl;

}

}

}

}

}

}

void find_car()

{

int id;

cout << "Enter the id of the car to be checked: ";

cin >> id;

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_rent_id() == id)

{

cout << "The car has been rented by a "

<< list[i]->get_type() << " customer." << endl;

return;

}

}

cout << "A car with given id has not been rented by any customer." << endl;

}

void check_car()

{

int cid;

cout << "Enter the id of the car to be checked: ";

cin >> cid;

for (int i = 0; i<no_cars; i++)

{

if (inventory[i]->get_id() == cid)

{

if (inventory[i]->get_avail())

{

cout << "The car is not on rent." << endl;

}

else

{

cout << "The car is on rent." << endl;

}

return;

}

}

cout << "The car id is not found." << endl;

}

void check_cust()

{

int cid;

cout << "Enter the id of the customer to be checked: ";

cin >> cid;

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_cno() == cid)

{

if (list[i]->get_rent())

{

cout << "The customer has rented a car." << endl;

}

else

{

cout << "The customer has not rented a car." << endl;

}

return;

}

}

cout << "The customer id is not found.";

}

void privileges(string x)

{

if (x == "Regular")

{

cout << "Number of days car can be rented = "

<< reg_days << endl;

}

else if (x == "Corporate")

{

cout << "Number of days car can be rented = "

<< cor_days << endl;

}

else

{

cout << "Number of days car can be rented = "

<< vip_days << endl;

}

}

void change_priveleges()

{

int ch;

cout << "Enter the type of the customer to be changed: " << endl;

cout << "1-> Regular" << endl;

cout << "2-> Corporate" << endl;

cout << "3-> VIP" << endl;

cin >> ch;

while (ch<1 || ch>3)

{

cout << "Enter a valid choice->(1/2/3)" << endl;

cin >> ch;

}

if (ch == 1)

{

cout << "Enter the new number of days"

<< " for which the car can be rented"

<< " to regular customers->" << endl;

cin >> reg_days;

}

else if (ch == 2)

{

cout << "Enter the new number of days"

<< " for which the car can be rented"

<< " to corporate customers->" << endl;

cin >> cor_days;

}

else

{

cout << "Enter the new number of days"

<< " for which the car can be rented"

<< " to VIP customers->" << endl;

cin >> vip_days;

}

}

void remove_car()

{

if (no_cars == 0)

{

cout << "The inventory is already empty." << endl;

return;

}

int rem_id;

cout << "Enter the id of the car to be removed: ";

cin >> rem_id;

Car *rem = NULL;

for (int i = 0; i<no_cars; i++)

{

if (inventory[i]->get_id() == rem_id)

{

rem = inventory[i];

if (!(rem->get_avail()))

{

cout << "This car is rented to"

<< " a customer and hence, can not be removed."

<< endl;

return;

}

inventory[i] = inventory[no_cars - 1];

inventory[no_cars - 1] = NULL;

no_cars--;

}

}

if (rem == NULL)

{

cout << "ID not found.";

}

else

{

cout << "Removed" << endl;

}

}

void add_customer()

{

int type;

cout << "Which type of customer do you wish to add:"

<< endl;

cout << "1-> Regular" << endl;

cout << "2-> Corporate" << endl;

cout << "3-> VIP" << endl;

cin >> type;

while (type<0 || type > 3)

{

cout << "Enter a valid choice(1/2/3)";

cin >> type;

}

if (type == 1)

{

list[no_cust++] = new reg_customer();

}

else if (type == 2)

{

list[no_cust++] = new cor_cust();

}

else if (type == 3)

{

list[no_cust++] = new vip_customer();

}

}

void rem_cust()

{

if (no_cust == 0)

{

cout << "The list of the customers is empty->";

return;

}

int cid;

cout << "Enter the id of the customer to be removed: ";

cin >> cid;

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_cno() == cid)

{

if (list[i]->get_rent() == 1)

{

cout << "This customer currently has a car on rent"

<< " and hence, can not be removed" << endl;

return;

}

list[i] = list[no_cust - 1];

list[no_cust - 1] = NULL;

no_cust--;

break;

}

}

}

void rent_car()

{

int cno;

int id;

int index_car = -1;

int index_cust = -1;

cout << "Enter the id of the customer to rent a car: ";

cin >> cno;

cout << "Enter the id of the car to be rented: ";

cin >> id;

for (int i = 0; i<no_cars; i++)

{

if (inventory[i]->get_id() == id)

{

if (!(inventory[i]->get_avail()))

{

cout << "This car is currently"

<< " rented to some other customer." << endl;

return;

}

index_car = i;

break;

}

}

if (index_car == -1)

{

cout << "Car Not found." << endl;

return;

}

for (int i = 0; i<no_cust; i++)

{

if (list[i]->get_cno() == cno)

{

index_cust = i;

break;

}

}

if (index_cust == -1)

{

cout << "Customer not found." << endl;

return;

}

if (list[index_cust]->get_type() == "Regular")

{

int rent_days;

cout << "Enter the no of days to rent the car: ";

cin >> rent_days;

while (rent_days>reg_days)

{

cout << "Regular customers can rent a car for maximum "

<< reg_days << " days.";

cout <<endl<< "Enter the no of days to rent the car: ";

cin >> rent_days;

}

if (inventory[index_car]->get_type() == "Standard")

{

inventory[index_car]->set_avail(0);

list[index_cust]->set_rent(1);

list[index_cust]->set_days(rent_days);

list[index_cust]->set_rent_id(inventory[index_car]->get_id());

cout << "Operation sucessful." << endl;

}

else

{

cout << "Regular customer can"

<< " only avail standard cars." << endl;

}

}

else if (list[index_cust]->get_type() == "Corporate")

{

int rent_days;

cout << "Enter the no of days to rent the car: ";

cin >> rent_days;

while (rent_days>cor_days)

{

cout << "Corporate customers can "

<< "rent a car for maximum " << cor_days << " days.";

cout <<endl << "Enter the no of days to rent the car: ";

cin >> rent_days;

}

inventory[index_car]->set_avail(0);

list[index_cust]->set_rent(1);

list[index_cust]->set_days(rent_days);

list[index_cust]->set_rent_id(inventory[index_car]->get_id());

cout << "Operation sucessful." << endl;

}

else

{

int rent_days;

cout << "Enter the no of days to rent the car: ";

cin >> rent_days;

while (rent_days>vip_days)

{

cout << "VIP customers can rent a car for maximum "

<< vip_days << " days.";

cout <<endl<< "Enter the no of days to rent the car: ";

cin >> rent_days;

}

inventory[index_car]->set_avail(0);

list[index_cust]->set_rent(1);

list[index_cust]->set_days(rent_days);

list[index_cust]->set_rent_id(inventory[index_car]->get_id());

cout << "Operation sucessful." << endl;

}

}

//Define the destructor

//to free the allocated memory.

~CarRentalManagement()

{

for (int i = 0; i<no_cust; i++)

{

delete list[i];

}

for (int i = 0; i<no_cars; i++)

{

delete inventory[i];

}

}

};

int main()

{

//Define an object

//of CarRentalManagement type.

CarRentalManagement ob;

//Call the display function

//to show the available

//choices to the user.

ob.display();

//Remove system("pause")

//if not using visual studio.

system("pause");

return 0;

}

Sample Output:

Please choose one of the following options: a) Add a new car to the inventory b) Remove an existing car from the inventory c)j) Determine whether a given customer has rented a car k) Determine whether a given car is a rented by a regular customer, co3-> VIP 2 Enter the customer number 2 Enter the address of the customer: Street U Enter the tel no of the customer: 112233113c) Register new customers d) Remove a given customer from the customers list e) Rent a car to a customer f) Return a car andm) Exit Enter the id of the car to be checked: 1 The car is on rent. Please choose one of the following options: a) Add a newh) Change the privileges i) Determine whether a given car is rented or not j) Determine whether a given customer has rented ac) Register new customers d) Remove a given customer from the customers list e) Rent a car to a customer f) Return a car andPlease choose one of the following options: a) Add a new car to the inventory b) Remove an existing car from the inventory c)1) Determine the types of cars rented by a customer of a given company m) Exit Enter the id of the customer to be removed: 1

Add a comment
Know the answer?
Add Answer to:
Car Rental Management System The aim of this project is to design and implement a computerized...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Description: The car rental company allows customers to reserve rental cars over the internet, the company...

    Description: The car rental company allows customers to reserve rental cars over the internet, the company also allows customers to rent cars by calling up car rental personnel or by walking up to the rental counter. The rental car company has a number of branches and each car is assigned to a home branch. Cars are always rented from the home branch but may be returned to a different branch. Cars are sometimes shifted from location to location – i.e....

  • Consider an online rental car reservation system that works with multiple rental companies in the same...

    Consider an online rental car reservation system that works with multiple rental companies in the same way one can reserve a car at expedia.com with Hertz, Alamo, etc. Consider the following use case: UC1. Customer makes reservation 1. The customer logs in the system. 2. The customer selects a start day and an end date/time, pickup and drop-off locations. 3. The system displays a list of cars for the above parameters. 4. The customer selects a car from the list...

  • An auto rental company wants to develop an automated system that can handle car reservations, customer...

    An auto rental company wants to develop an automated system that can handle car reservations, customer billing, and car auctions. Usually a customer reserves a car, picks it up, and then returns it after a certain period of time. At the time of pickup, the customer has the option to buy or waive collision insurance on the car. When the car is returned, the customer receives a bill and pays the specified amount. In addition to renting cars, every six...

  • DVD Rental System Develop a DVD/CD Rental System for a shop that rents out DVDs and...

    DVD Rental System Develop a DVD/CD Rental System for a shop that rents out DVDs and VCDs to its registered customers. The system need to keep track of its rental information and compute rental fees collected from DVDs and CDs rented out to customers. This DVD Rental System is to be developed with methods using the Java programming language. The DVD rental shop has several DVDs and CDs, and many customers. Each customer is allowed to rent maximum of five...

  • Only Answer Part B please. Part 1 One-way ANOVA (35 points) A rental car company wants...

    Only Answer Part B please. Part 1 One-way ANOVA (35 points) A rental car company wants to investigate whether the type of car rented affects the length of the rental period. An experiment is run for one week at a particular location, and 4 rental contracts are selected at random for each car type. The results are shown in the following table. Car type Observations (# of days) Compact Midsize 7 3 16 15 6 8 7 9 Full size...

  • Can someone who knows how to draw data model on mySQL help me out? Budget car...

    Can someone who knows how to draw data model on mySQL help me out? Budget car rental company has offices located across the continental USA. They would like to track the local address ( all pieces address, state, city, zip),and the contact phone number for that office location. They would also like information about employees working at that office including their names, date of birth, start of employment, contract phone number, and roles. Offices typically have more than one employee...

  • Management Informtion Systems. Question: create a flow chart from the scenario below: -I am starting up...

    Management Informtion Systems. Question: create a flow chart from the scenario below: -I am starting up a local car rental company. With this system a Customer can rent a car from me based on the car’s make and model. This system provides customer to have different pick-up and drop-off locations and will impose late fee if the rental car is returned beyond the return date and time. The Customers can purchase car rental insurance which is optional and can use...

  • Solve it in access Group Project Note: All documents should be prepared and presented in a...

    Solve it in access Group Project Note: All documents should be prepared and presented in a professional manner, with a cover page showing the group number and the names of group members. Nothing should be hand written hand drawn Michiana Car Rentals Database System Michiana Car Rentals, Inc., headquartered in South Bend, IN, wants to build a database system which would track information customer billing. Usually, a customer picks up a car and then returns after a period of time....

  • in Python The program will compute and display information for a company which rents vehicles to...

    in Python The program will compute and display information for a company which rents vehicles to its customers. For a specified customer, the program will compute and display the amount of money charged for that customer’s vehicle rental. 1. The program will repeatedly prompt the user to enter the following four items for a given customer (in the specified order): a. The customer's classification code (a character) b. The number of days the vehicle was rented (a number) c. The...

  • Sundown Rent-a-Car, a large automobile rental agency operating in the Midwest, is preparing a leasing strategy for the next six months

    Sundown Rent-a-Car, a large automobile rental agency operating in the Midwest, is preparing a leasing strategy for the next six months. Sundown leases cars from an automobile manufacturer and then rents them to the public on a daily basis. A forecast of the demand for Sundown’s cars in the next six months follows:MONTH MARCH APRIL MAY JUNE JULY AUGUSTDemand 420 400 430 460 470 440Cars may be leased from the manufacturer for either three, four, or five months. These are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT