Question
This program simulates the cost of building a deck on a house. The customer is asked for their name, telephone number and email address. The
This program simulates the cost of building a deck on a house. The customer is asked for their name, telephone number and email address. The customer is then asked to select the shape of the deck (rectangular, circular or trapezoidal) and the material used to build the deck (Wood or Trex).
The total price is calculated using the square feet of the deck and the materials used, plus tax. An estimate is presented to the customer and then the customer may select another estimate. The program must repeat until the customer expressly states that they do not want to receive another estimate.
Step 1: Call a welcome function that displays the name of the program, the copyright statement and includes the name of the deck building company with your name as the owner.
prototype: void welcome();
Step 2: Call the get Info function that will ask the customer for their name, telephone number and email address. Enter a name and a fictitious telephone number and email address. You must use both the first and last name with a space in between. This information must be gathered once and reused even if the customer wishes to get additional estimates. prototype: void get Info(string &, string &, string &);
Step 3: Start a loop that will encompass most of the body of the code. It will end just before the last function call which must display the goodbye message. The loop must continue until the user expressly states that they do not want to receive additional estimates.
Step 4: Call the select Shape function in which a menu is presented, and the user is asked to indicate the shape of the deck (rectangular, circular, or trapezoidal). Use a local variable and return the variable back to the main function. Be sure to validate input in the function so that only rectangular, circular, or trapezoidal is selected. Any other selection must display an error message and allow the customer to reenter. prototype: int select Package Shape ();
Step 5: In the main function use a switch statement or an if/else statement to call functions that will (1) get the dimensions of the deck and (2) calculate the square feet. If the deck is rectangular, call these 2 functions only: prototypes: void getDimensions (double&, double&); //validate input double calcSquareFeet (double, double);
getDimensions allows the entry of the length and width. All must be greater than 0. The formula for area: area = length * width
NOTE: The total number of square feet MUST be less than or equal to 308. If the calculated amount is greater than 308, the program must display an error message and the customer must reenter the length and width. If the deck is circular, call these 2 functions only: prototypes: void getDimensions(double &); // validate input double calcSquareFeet (double);
getDimensions allows the entry of the diameter. The input MUST be of the diameter, not the radius. This value must be greater than 0. Formula for area: volume = PI * radius * radius Declare PI (3.14) as a global constant.
NOTE: The total number of square feet MUST be less than or equal to 308. If the calculated amount is greater than 308, the program must display an error message and the customer must reenter the diameter. If the deck is trapezoidal, call these 2 functions only: prototypes: void getDimensions (double&, double&, double &); //validate input double calcSquareFeet (double, double, double);
getDimensions allows the entry of the short length, the long length and the height. All must be greater than 0. The formula for area: area = (short length + long length) /2 * height NOTE: The total number of square feet MUST be less than or equal to 308. If the calculated amount is greater than 308, the program must display an error message and the customer must reenter the short length, long length and height. NOTE: The functions getDimensions and calcSquareFeet MUST be overloaded functions! If the customer selects the get another estimate menu option, the code must call the function select Shape directly. There is no need to ask for name and number again.
Step 6: Call the select Material function in which a menu is presented, and the user is asked to select the material used to build the deck. Use a local variable and return that variable back to the main function. Be sure to validate input for the menu choice in the function. The wood price is $20.75 per square foot and the Trex price is $27.85 per square foot. These 2 values must be declared as global constants, which means you do not have to pass them to a function, but they must be used in the function. prototype: int select Material ();
Step 7: Call the calcTotalPrice function that accepts the material used and the calculated area and uses this information to calculate the value of the total price. Return the result of the calculation to main. Be sure to use the constants. The total price before taxes is the number of square feet * the cost per square foot of the material selected. prototype: double calcTotalPrice (int, double);
Step 8: Call the displayEstimate function that accepts the customer's name, telephone number, email address, calculated area, material used and total price. The code determines that taxable amount. 63% of the total price is the cost of the material, 37% is the cost for the labor. The sales tax is only on the cost of the material. The state sales tax rate is 6%. The code outputs the following: 1. The name, telephone number and email address of the customer 2. The total area of the deck 3. The material selected 4. The cost of the material per square foot 5. The total cost before taxes 6. The total taxes 7. The final cost (the total cost + the tax) Use the sample output for the complete estimate and the formatting. Be sure to use the constants. The message regarding a "valid estimate for 30 days" must be included in this function. Use the due date of this program in the estimate.
prototype: void displayEstimate (string, string, string, double, int, double);
Step 9: In the main function, ask the customer if they would like to get an estimate for another package. Be sure to validate input for the menu choice. If the customer enters yes (Y or y), the program must begin with selecting the package shape, etc. If the customer enters no (N or n), the loop ends and a goodbye function is called. Use your own creative ending. If the customer enters anything other than yes or no, the loop must state that this is an invalid response and ask for another entry. Once the user selects that they wish to stop, the code must call a goodbye function to display the goodbye message. This message can be anything you wish. prototype: void goodBye()
Extra Credit: Create a function that is called to test all numeric input to assure that the value is greater than 0. This must be used for entry of the length, width, diameter, short length, long length and height. This is worth 3 points of extra credit. For an additional 2 points of extra credit, make this function "smart". Create a function that not only displays an error for an incorrect response, but specifically states what value was entered incorrect. For example, instead of the program stating: "Error: Invalid Entry. Value must be greater than zero", the smart function will show the error message as: "Error: Invalid Entry. The width must be greater than zero".
NOTES: Select good variable and constant names that are descriptive. Comment each constant, variable, function and the code. In the functions that require local variables, it is perfectly alright to use the same variable name (ex: choice) as you used in the other functions. Remember that the scope of the variable stays within the block of code in which it is defined. Be sure to use the numbers on the test data so that the final estimates match. Use all the good programming techniques that you have been taught.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started