Functions to make a main program

Assignment Help C/C++ Programming
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;
}

 

 

Reference no: EM13165502

Questions Cloud

Modify the book class to accommodate multiple authors : modify the Book class to accommodate multiple authors using one of the components from the Java Collection Framework.
What is the empirical formula of the hydrocarbon : 4.236-g sample of a hydrocarbon (CxHy) is combusted in O2 completely to give 3.810 g of H2O and 13.96 g of CO2. What is the empirical formula of the hydrocarbon?
Write a test program that prompts the user : public static int binaryToDecimal(String binaryString)Write a test program that prompts the user to enter a binary string and displays its decimal equivalent.
What mass of iron would be required to cover : What mass of iron would be required to cover a football playing surface of 120 yds × 60 yds to a depth of 1.0 mm?
Functions to make a main program : write the required functions to make a main program that is already written
Length of the string in order to reserve space : To determine the length of the string in order to reserve space for the new string use the library routine strlen. Register a1 contains a pointer to the string to measure and on return register a1 has the number of characters in the string. You..
What is the boiling point of water in breckenridge : In Breckenridge, Colorado, the typical atmospheric pressure is 514 torr. What is the boiling point of water (ΔHvap = 40.7 kJ/mol) in Breckenridge?
Calculates the sum of the cube roots of two integers. : Wrtie a program that calculates the sum of the cube roots of two integers. The program should use the following functions as well as a main funcion. 1) enter one positive value 2) compute the cube root of one integer 3) report the value of two intege..
What was the initial concentration : A zero-order reaction has a constant rate of 1.60×10-4 . If after 35.0 seconds the concentration has dropped to 2.50×10-2 , what was the initial concentration?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd