Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a GiftWrap class that a gift wrapping store could use to calculate the price of wrapping rectangular gift boxes and generate invoices/receipts for their

Design a GiftWrap class that a gift wrapping store could use to calculate the price of wrapping rectangular gift boxes and generate invoices/receipts for their customers. The class will allow a gift wrapping store to calculate the cost of wrapping various sized rectangular boxes. The class will have member functions to calculate the price of the gift wrap box being wrapped, tax on the gift wrap sold, and the total cost of the gift wrap both including and excluding tax.

The class should have the following member variables:

length this variable holds the length of the box in inches

width this variable holds the width of the box in inches

height this variable holds the height of the box in inches

taxRate this variable holds the sales tax rate for the company

pricePerInch this variable holds the price per inch of the gift wrap

The class should have the following member functions:

Two Constructors:

One constructor should be a no argument (no arg) constructor. This constructor should set the length, width and height member variables to 1.0, the pricePerInch member variable to 0.0036, and the taxRate member variable to 0.08.

One constructor that accepts the following two values as arguments (so the constructor should have two parameter variables) and assigns them to the appropriate member variables: the tax rate and the price per inch. This constructor should set the length, width and length member variables to 1.0.

Do not allow the pricePerInch member variable to be set to numbers less than zero. Use reasonable default values. Its up to you to know how to design this based on class lecture on object oriented programming.

Do not allow the taxRate member variable to be set to a number less than zero or greater than one. Use reasonable default values. Its up to you to know how to design this based on class lecture on object oriented programming.

Five Set Functions:Design a set function for each member variable: length, width, height, pricePerInch, and taxRate.

Do not allow the length, width, height, and pricePerInch member variables to be set to numbers less than zero. Its up to you to know how to design this based on class lecture on object oriented programming.

Do not allow the taxRate member variable to be set to a number less than zero or greater than one. Its up to you to know how to design this based on class lecture on object oriented programming.

.

Five Get Functions:

Design get function for each member variable: length, width, height, pricePerInch, and taxRate

Its up to you to know how to design these functions based on class lecture on object oriented programming.

calcSubtotal Member Function:

This member function should calculate the price of the gift wrap BEFORE tax. The price of the gift wrap before tax is calculated as follows:

1.First calculate the surface area of the box.

Surface Area = (2 * length * width) + (2 * length * height) + (2 * width * height)

2.Next multiply the surface area of the box by the price per inch. This is the subtotal for the gift wrap.

calcTax Member Function:

This member function should calculate the tax on the gift. The tax is the subtotal * the tax rate. Be efficient and use existing functions if you can.

calcTotal Member Function:

This member function should calculate the overall total price of the gift wrap which is the subtotal + the tax. Be efficient and use existing functions if you can.

Step 2: Create a Program to test utilize the GiftWrap class

Next create a program to utilize and test the GiftWrap class. This program is for a small gift store called Sallys Gifts. (HINT: keep your program simple)

First steps: First create a string type variable to hold the name of the gift store: Sallys Gifts. Next, use the constructor that takes two arguments to instantiate a GiftWrap object/instance named sallys. When you call the constructor pass in .0925 for the tax rate and .0025 for the price per inch of the gift wrap.

Next: Display the following menu:

GIFT WRAP INVOICE GENERATOR

-------------------------------

a)Generate Gift Wrap Invoice

q)Quit

--If the user enters a or A:

First, ask the user the length of the box being wrapped and call the proper class member function. Then ask the user the width of the box being wrapped and call the proper class member function. Than ask the user the height of the box being wrapped and call the proper class member function. Make sure and handle any input validation issues as needed using the techniques we learned in class during the object oriented lecture (you should know them for listening to lecture).

Next, display a gift wrap invoice/receipt similar to the once below (make sure and format it) by calling the proper class member functions (use a variable to print the company name, dont hard code it):

GIFT WRAP INVOICE - Sally's Gifts

----------------------------------

Box Length: 10.0

Box Width: 10.0

Box Height: 10.0

Price Per Inch: 0.0025

SUBTOTAL: 1.50

TAX: 0.14

----------

TOTAL: 1.64

--If the user enters anything other than a, A, Q or q:

- Print the message Invalid Selection

--The user should be able to generate as many gift wrap invoices for Sallys as they want until they select q or Q to quit

--If the user enters q or Q quit the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions