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

  The funtion should take as parameters

Write a function in c ++ that multiplies two functions. the funtion should take as parameters two fraction structures. Then, the function should multiply the two fractions and return the solution as a fraction structure.

  C assignment of curl library

C Assignment Curl library must be used To be done on linux, it should be compiled using the following command: gcc -Wall -ansi -pedantic NameOfFile.c -lncurses Please make sure it is commented with clarification Variable names in camel case

  Returns a count of the steps through the sort

Please write a c++ implimentation that returns a count of the steps through the sort. (do not worry about updating count, I will rewrite that segemnt. I need help with writing the shell sort.

  Write a count occurrences() function that accepts a string

Write a CountOccurrences() function that accepts a string to be searched and a sub-string to be found. The function should return the # of times the sub-string is found. Write a tester file that declares a secret sentence as a constant.

  Write a program with a while loop to print 1 to n in square

Write a program with a while loop to print 1 to N in square brackets. N is an integer input from the user. (i) Write the same program using a for-loop

  Implement a simplified version of the set class

You will implement a simplified version of the set class. You must implement all functions defined in the provided file set.h. You may add other member functions and variables as necessary.

  Prompts the user to enter an integer

Write the code that prompts the user to enter an integer between 1 and 20 (including 1 and 20), reads the value using cin, and then prints the value that they entered in a statement that begins with "You entered a ". Save this version in a separate l..

  C++ programming uml diagrams

The goal of this lab is to better familiarize you with polymorphism and the factory design pattern, two key components in Assignment

  Write a program that contains a main function

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point

  Write a program to find out all 3-digit

Write a program to find out all 3-digit Narcissistic number. A number n is a 3-digit Narcissistic number if: (a) 100   n   999, (b) The sum of its own digits each raised to the power of 3 equals to itself. For example: 153 is a Narcissistic number ..

  Write a program to calculate the area of a circle

Write a program to calculate the area of a circle. The program should use two procedures. The first procedure will print out the program heading and ask the user to enter the radius. The second procedure should calculate the area. The area of the cir..

  Create a structure that has one variable called value

"Create a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list. Print out the current contents of the list.

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