Reference no: EM13165502
write the required functions to make a main program that is already written
// Purpose: This program simulates a calculator for how much a customer needs to pay
// for car rentals depending on his/her subscriptions
//---------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
// Rental companies
const char HERTZ = 'H';
const char AVIS = 'A';
// Vehicle types
const int SEDAN = 1;
const int TRUCK = 2;
const int MINIVAN = 3;
const int SPORTSCAR = 4;
// Rental types
const char DAILY = 'D';
const char WEEKLY = 'W';
const char MONTHLY = 'M';
// Daily vehicle costs
const float SEDAN_COST = 8.50;
const float TRUCK_COST = 10.00;
const float MINIVAN_COST = 16.50;
const float SPORTSCAR_COST = 17.50;
// Discounts
const float HERTZ_DISCOUNT = 0.10; // 10 percent
const float AVIS_DISCOUNT = 0.15; // 15 percent
//---------------------------------------------------------------------------
// Name: GetCompany
// Parameters: Question, string, input: The question to ask the user
// Returns: char, uppercase, the company the user chooses
// Purpose: Ask the user to enter a letter indicating a company
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: GetVehicleType
// Parameters: None
// Returns: int The type of vehicle selected
// Purpose: Asks the use what type of vehicle they want
// NOTE: Called by GetRentalInfo
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: GetRentalType
// Parameters: None
// Returns: char The type of rental (DAILY, WEEKLY, MONTHLY) selected
// Converts character entered to uppercase letter
// Purpose: Asks the user what type of rental they want
// NOTE: Called by GetRentalInfo
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: GetRentalInfo
// Parameters: Pass by reference: VehicleType, int, RentalType, char.
// Input: Type of vehicle and type of rental
// Returns: N/A
// Purpose: Get the type of vehicle and the type of rental the user chose
// NOTE: This function MUST CALL GetRentalType and GetVehicleType
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: GetLength
// Parameters: TimePeriod, string, input: The question to ask the user
// Returns: int, Length, the length of rental the user chooses
// Purpose: Ask the user to enter a number representing the length of rental
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: GetCost
// Parameters: VehicleType, int, RentalType, char, input: To determine the cost of rental
// Returns: float, Cost, the cost of rental
// Purpose: Calculate the cost of rental based on the type of vehicle and the type of rental
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: EligibleForDiscount
// Parameters: CompanyUsed, char, CompanySubscribed, char,
// input: To compare if CompanyUsed equals to CompanySubscribed
// Returns: bool, the comparison is "true" or "false"
// Purpose: To determine if the user has subscription with the company he/she
// wishes to rent from.
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: ApplyDiscount
// Parameters: Pass by reference, Cost, float. Pass by value, CompanySubscribed, char,
// input: Apply discount to cost based on company subscribed
// Returns: N/A
// Purpose: Apply discount to the rental cost based on the user's subscribed rental company
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Main program
//---------------------------------------------------------------------------
int main ()
{
// Declarations
char CompanySubscribed; // The company you have a subscription at
char CompanyUsed; // The company you wish to rent from
int VehicleType; // The type of vehicle you want to rent
char RentalType; // Whether you are renting by the day, week, month
float Cost; // The cost of your rental
// print name and UAID
cout << "###################\n";
cout << "### Name ###\n";
cout << "### UAID ###\n";
cout << "###################\n\n";
// Print the program information
cout << "------------------------------------------------------------------------\n";
cout << "There are two main rental comapnies for renting vehicles, "
<< "Hertz and Avis.\n";
cout << "\nEach of these rental companies rents four types of vehicles: "
<< "Sedan, Truck, Minivan, or Sportscar.\n";
cout << "Based on your type of vehicle, and length of rental, we will figure out "
<< "how much you owe the rental company.\n";
cout << "------------------------------------------------------------------------\n";
/* Commented out so shell will compile
// Get information from the user
CompanySubscribed = GetCompany("\nWith which company do you have a subscription?");
CompanyUsed = GetCompany("\nFrom which company do you wish to rent?");
GetRentalInfo(VehicleType, RentalType);
// Calculate the cost
Cost = GetCost(VehicleType, RentalType);
cout << "\nThe full cost or your rental is: $"
<< fixed << showpoint << setprecision(2) << Cost << ".\n";
// Apply any discounts
if (EligibleForDiscount(CompanyUsed, CompanySubscribed))
{
ApplyDiscount(Cost, CompanySubscribed);
cout << "\nAfter your discount, your rental is: $"
<< fixed << showpoint << setprecision(2) << Cost << ".\n";
}
end of commented out section */
return 0;
}