Question: Assignment ID: proj2 File(s) to be submitted: gaspump.h, gaspump.cpp, proj2.cpp, makefile BV Objectives: 1) Use classes; 2) Split interface and implementation into files; 3) Use

 Assignment ID: proj2 File(s) to be submitted: gaspump.h, gaspump.cpp, proj2.cpp, makefileBV Objectives: 1) Use classes; 2) Split interface and implementation into files;

Assignment ID: proj2 File(s) to be submitted: gaspump.h, gaspump.cpp, proj2.cpp, makefile BV Objectives: 1) Use classes; 2) Split interface and implementation into files; 3) Use an array of pointers to objects; 4) Instantiate objects using parameterized constructors; 5) Use objects in a client/driver function. Project description: In this assignment you will create a class representing a gasoline pump. The pump will maintain a running total of the amount of fuel dispensed and revenues collected. The driver program instantiates 3 pumps, and simulates fuel demand for a number of vehicles. Requirements: 1. Your program must be split into three files, the requirements for which are specified below: a) The class interface, or declaration, file . . Must be named gaspump.h Must contain #include guards for GASPUMP_H Class must be named GasPump Will have these private members i. A string containing the type of gas the gas pump holds ii. A double that holds the price per gallon iii. A double representing the total amount of fuel dispensed (all purchases) iv. A double that stores the total amount of money collected (all purchases) Must have these public members i. A single constructor with two parameters (in order): a standard string (std::string) that holds the type of gasoline in the pump, and a double for the price per gallon. ii. An inline accessor function that returns a standard string for the pump's fuel type iii. An inline accessor function that returns a double for the pump's fuel price per gallon iv. An inline accessor function that returns the total amount of fuel dispensed (all purchases) V. An inline accessor function that returns the total amount of revenue collected (all purchases) vi. A function dispenseFuel, that dispenses fuel to vehicles. . b) A class implementation, or definition, file . Must be named gaspump.cpp Will have the implementation for the following functions i. Constructor - With two parameters (in this order): fuel type (string), and price per gallon (double). ii. dispenseFuel - This function is the heart of the class, and controls the fueling of a single vehicle. It has one parameter: a double that indicates the monetary purchase desired by the vehicle, and returns a double representing the number of gallons the vehicle received. This function: A. Converts the purchase amount to gallons of fuel. B. Accumulates total fuel dispensed C. Accumulates total revenue collected D. Returns the number of gallons the vehicle received (a double) c) A driver, or client, file O o o . Must be named proj2.cpp Reads input data from a file named gas.txt, that will be formatted as follows: The first line is a random number seed (integer) The second line is the number of vehicles to be run through the simulation The 3rd through 5th lines represent individual gas pumps (one per line), composed of: Gasoline type (string) Cost per gallon (double) Declares an array of pointers to three (3) GasPump objects, and instantiates each GasPump using data read from the input file. Sets the random number generator seed, using srand(), to the value read from the input file: Creates a loop for the number of vehicles to be simulated - one vehicle per iteration: Determine the array index for the pump the vehicle will fuel from, by drawing a random integer with rand and modding it by 3. Determine the amount of money the vehicle wants to spend on fuel Select random values from $30 to $50 in increments of $5, by drawing a random integer with rand, modding it by 6, multiplying the result by 5, and adding 25 to it. o Use the pointer at the index to invoke the dispenseFuel function in the appropriate pump Output a single line containing the following (in order): Vehicle #, fuel type, price per gallon, purchase amount, gallons received. Note: For output main must get the fuel type, price per gallon, and gallons received from the GasPump objects. It may not store or calculate this information. Upon exiting the loop, output the total fuel dispensed and total revenue collected for each pump (in order) o 2. Sample Output- This is the output from running with the provided sample input file. The format of your output MUST MATCH EXACTLY the output in this specification. DO NOT add any verbiage or information beyond what is shown. Place the following lines prior to entering the loop processing vehicles, to ensure proper formatting: std::cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!