Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Resin Molds Judy runs a shop that sells molds used in arts and crafts, specifically for use with resin. The molds are made of silicone

Resin Molds
Judy runs a shop that sells molds used in arts and crafts, specifically for use with resin. The molds are made of silicone and come in various shapes and sizes. Each mold weighs a different amount which affects the shipping cost. Judy needs a program to help her process orders for her molds. You will create a program that allows Judy to enter an order for a mold and create an invoice in the form of an output file.
Start by creating an enum that represents the different possible sizes of molds. Then you will create a struct that represents the molds. To keep track of the order, you will also need to create a customer struct and an order struct. The specifications for the enum and structs are listed below.
Size Enumeration
Name
sizeType
Enumerators (Printed Name)
S ("Small")
M ("Medium")
L ("Large")
Mold Struct
Name
moldType
Members
shape : string
size : sizeType
price : double
weight : double
Customer Struct
Name
customerType
Members
fname : string
lname : string
address : string
Order Struct
Name
orderType
Members
customer : customerType
products : moldType []
numProdOrdered : int
subTotal : double
totalWeight : double
shippingCost : double
The catalog of products currently available will be kept in catalog.txt. Judy keeps 20 products in stock at a time. These are the products that will be ordered by customers. You will need to create the following functions to set up Judy's program.
Function 1
Name
readCatalog
Parameters
productCatalog : moldType[]
numProducts : int
Return Type
void
Description
This function reads catalog.txt. Each line of the file contains information about a mold that is currently for sale. Because she is frequently rotating stock around, this file will change and have different information in it (you cannot hardcode the data into the program).
Function 2
Name
enterOrder
Parameters
order : orderType& (by reference)
catalog: moldType[]
numItemsInCatalog : int
Return Type
void
Description
This function prompts the user for the information pertaining to an order. It will provide options that allow for up to 10 products to be selected. It will store the order information in the reference parameter. The shipping cost is calculated based on weight using the formula .
Function 3
Name
printProduct
Parameters
ostream& (output stream by reference, either a file or the console)
mold : moldType
Return Type
void
Description
This function takes the information about a mold and prints it using the output stream provided. This allows us to print to either a file or the console with the same function.
Function 4
Name
printOrder
Parameters
ostream& (output stream by reference, either the console or a file)
orderType& (the order we are going to print)
Return Type
void
Description
This function takes the information about an order and prints it to the stream that is given as a parameter. This allows the function to output to multiple sources, like an output file or the console.
For the main, you will first need to read the current product catalog into an array of moldType. Next, you will get the order information from Judy. You will output the order to the console and to a file named using the customer's last name. Lastly, you will ask if Judy wants to enter any more orders. If she answers "n," exit the program; if she answers "y," repeat the process of getting order information and creating a new output file. here is catalog.txt "Pendant M 17.1048
Dragon L 108.76200
Heart S 26.6822
Ornament M 33.52101
Seahorse L 33.52111
Domino L 54.04145
Tree L 67.72132
Flower S 26.6856
Coaster M 13.0043
Keychain S 25.4548
Sun L 74.56125
Geode M 40.3687
Angel M 35.4174
Butterfly S 14.6536
Rose S 18.6544
Spider M 32.5489
Bubble S 24.5742
Tray L 60.88143
Lizard M 34.26112
Turtle M 42.12125" and here is parker.txt "Customer: Peter Parker
112 Main St.
Queens, NY 11415
Products Ordered:
Pendant - Medium $17.1048.00g
Ornament - Medium $33.52101.00g
Spider - Medium $32.5489.00g
Lizard - Medium $34.26112.00g
Turtle - Medium $42.12125.00g
Tree - Large $67.72132.00g
Tray - Large $60.88143.00g
Coaster - Medium $13.0043.00g
Seahorse - Large $33.52111.00g
Rose - Small $18.6544.00g
Subtotal: $353.31
Total Weight: 948.00g
Shipping Cost: $19.39
Total Cost: $372.70" here is stark.txt "Customer: Tony Stark
200 Park Ave
New York, NY 10166
Products Ordered:
Turtle - Medium $42.12125.00g
Sun - Large $74.56125.00g
Keychain - Small $25.4548.00g
Subtotal: $142.13
Total Weight: 298.00g
Shipping Cost: $6.10
Total Cost: $148.23" be sure to use all three files when writing the code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions