Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a program which can implement a car rental management system, all the spe

ID: 3818173 • Letter: D

Question

Design a program which can implement a car rental management system, all the specifics of different cars, their models, their prices should be incorporated. In addition, the program must store credentials of a customer, whether he/she is an old customer or not? Whether a security deposit is required or some kind of verification is required or not. We can also apply certain discounts for repeating customer, discounts may also be offered if the rental agreement is for more than a specified number of days. In case of an accident, proper information must be entered in system against that customer which should be part of his/her record for future. Number of miles/km allocated per car, per day must be entered, if a car is going extra miles, user must be charged accordingly, if a car is going out of city, this permission should be granted at the time of booking. Maintain complete record of all cars and all customers, the program should also maintain service history of each vehicle and should intimate when any kind of maintenance is required. At the end the program should report actual revenue earned.

Explanation / Answer

CODE: carRental.cpp

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
string name;
// carDetails stores all the information about the car.
   map<string,int> carDetails;
  
   // customerNames stores all the customer names.
vector<string> customerNames;
  
int carKm = 0;
int days = 0;
int carModel = 0;
int rentalfee = 0;
int perKm = 0;
float totalAmount = 0, amount = 0;
float discountValue = 0;
bool discount = false;
int carUseRange = 0;
   char toContinue;
  
   cout<<"============================================================"<<endl;
   cout<<"WELCOME To CAR RENTAL SYSTEM" << endl;
   cout<<"============================================================"<<endl;

// Feed the car details here.
// carDetails is a map having carName and price as (key,value) pair
// Please edit here for Car names and the corresponding prices.
   carDetails["Model 1"] = 50000;
carDetails["Model 2"] = 40000;
carDetails["Model 3"] = 30000;
carDetails["Model 4"] = 20000;
carDetails["Model 5"] = 10000;

   while(1){
       cout << "Please provide customer Name: " << endl;
       cin >> name;
      
       // check if the customer name is already there in the list. If yes, then discount is applicable.
       // else, add the name to the list.
       if (find(customerNames.begin(), customerNames.end(), name) !=    customerNames.end()){
           customerNames.push_back(name);
       }   
       else{
           discount = true;
       }

     
           cout << "Please provide Car Model Description"<< endl;
           cout<<"Enter 1 for Model 1"<< endl;
           cout<<"Enter 2 for Model 2"<< endl;
           cout<<"Enter 3 for Model 3"<< endl;
           cout<<"Enter 4 for Model 4"<< endl;
           cout<<"Enter 5 for Model 5"<< endl;

           cin >>carModel;
     
           cout << "Please enter the approximate KMs you want to use the car for" << endl;
           cin >> carKm;

           cout << "Please enter the number of days you want to rent for" <<endl;
           cin >> days;

      
           switch(carModel){
               case 1: rentalfee = days * carDetails["Model 1"];
                       discountValue = 0.10;
                       perKm = 20;
                       break;
           case 2: rentalfee = days * carDetails["Model 2"];
               discountValue = 0.08;
               perKm = 15;
               break;
           case 3: rentalfee = days * carDetails["Model 3"];
               discountValue = 0.06;
               perKm = 12;
               break;
           case 4: rentalfee = days * carDetails["Model 4"];
               discountValue = 0.05;
               perKm = 10;
               break;
           case 5: rentalfee = days * carDetails["Model 5"];
               discountValue = 0.04;
               perKm = 8;
               break;
       }

       amount = rentalfee + (perKm * carKm) + (2 * days);
           if (discount)
           totalAmount = discountValue * amount;
       else
       totalAmount = amount;
          
           cout << "Please find the Car rent applicable as below" << endl;
           cout << "NOTE: In case of unfortunate incidents, the complete cost has to be bourne by the customer. For ex: Damages related to accident" << endl;
       cout << "=============================================" << endl;  
       cout << "Customer Name: " << name<<endl;
           cout << "Car Model: " << "Model " << carModel <<endl;
       cout << "Planned KMs to Drive: " << carKm << endl;
           cout << "Number of days: "<< days << endl;
           cout << "Your Rental Amount is: "<< rentalfee << endl;
           if(discount){
       cout << "Since you are returning customer, you are eligible for discount !!!!" << endl;
       }
           cout << "Total Amount payable is: " << totalAmount << endl;
           cout << "=============================================" << endl;
          
       cout << "Press 'y' to continue and 'n' to exit" << endl;
       cin >> toContinue;
      
       if (toContinue == 'n')
           break;
}
}

$ g++ carRental.cpp
$ ./a.out
============================================================
WELCOME To CAR RENTAL SYSTEM
============================================================
Please provide customer Name:
Mark
Please provide Car Model Description
Enter 1 for Model 1
Enter 2 for Model 2
Enter 3 for Model 3
Enter 4 for Model 4
Enter 5 for Model 5
1
Please enter the approximate KMs you want to use the car for
50
Please enter the number of days you want to rent for
5
Please enter the options below
1. Taking car out of the city
2. Using the car withing city limits
2
Please find the Car rent applicable as below
NOTE: In case of unfortunate incidents, the complete cost has to be bourne by the customer. For ex: Damages related to accident
=============================================
Customer Name: Mark
Car Model: Model 1
Planned KMs to Drive: 50
Number of days: 5
Your Rental Amount is: 250000
Since you are returning customer, you are eligible for discount !!!!
Total Amount payable is: 25101
=============================================

Press 'y' to continue and 'n' to exit
n

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote