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 a customer profile class.

a. Create a CustomerProfile class. Each CustomerProfile contains a last name, phone number, and bit fields indicating whether the customer:

  Design class for textbook-data field for grade level of book

Design a class named TextBook that is child class of Book. Include new data field for grade level of book. Create a displayTextBookInfo () method so that you can accommodate new grade-level field.

  Structured programming using procedural languages

A a program that is called "Playing with Numbers or Letters".

  C++ pointer function synopsis

C++ pointer Function Synopsis: char *amonthLess(char *dateString) Description: Variable dataString is a valid date in a form of mm/dd/yyyy Given the above information, write a main() program that asks a user to enter a date in a form of mm/dd/yyyy..

  Create a graphical (not text-based) visual c++ program

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  Calculate the net pay as the gross less the taxes

Design and code a new function that accepts as parameters the gross pay by value and the federal tax, state tax, local tax, SS tax, and net Pay by reference.

  Write a program that asks the user to enter two numbers.

Starting Out with C++ Write a program that asks the user to enter two numbers.

  Lu decomposition with gauss elimination

The LU decomposition with Gauss elimination and what is the physical interpretation of the elements of ? Write C++ programs for steps 2, 3, and 4.

  Write a linked-list-based push-down stack implementation

Write a linked-list-based push-down stack implementation that keeps items on the list in order from least recently inserted to most recently inserted. You will need to use a doubly linked list.

  Write a program that converts between app and ppm values

Write a simple program that converts between APP and PPM values

  Write two short c programs and solve exam-style problem

Write two short C programs and solve four exam-style problems.

  Method celsius return celsius equivalent of fahrenheit

Method Celsius return the Celsius equivalent of a Fahrenheit temperature,using the calculation Celsius = 5.0/9.0*(Fahrenheit -32); method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation  Fahrenheit = 9.0/5..

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