Question: I ' m having a hard time figuring out the structure of the two cpp files and the header file. Thanks! # Farmers Market Booth
Im having a hard time figuring out the structure of the two cpp files and the header file. Thanks!
# Farmers Market Booth
## Objectives
Demonstrate knowledge about the following topics:
Functions
Namespaces
Pass by Reference
### The Problem to Solve
A local farmers market booth sold strawberries. Customers loved their strawberries so much that
the booth owners decided to start selling strawberry related products alongside the
strawberries. These strawberry products included strawberry jam, chocolate covered
strawberries, and glazed strawberry scones.
Before the addition of the strawberry products it was easy for the booth owners to keep track of
the profit from the strawberry sales since raw, freshly grown products receive the discounted
tax rate of However, prepared products do not. Instead, they are taxed at the usual rate of So the strawberry booth owners hired you
to create a basic program to correctly calculate the total for each sale.
This program needs to calculate the tax based on the last inputted product. It should then update the customer's total with that last product's price tax.
### Files to Work on
You will be working in the following files:
All functions will be part of the library order. The library consists of these two files:
srcordercpp
srcorderh
Our "driver" file will be
srcmaincpp
## Order Library
Create a library of functions to handle tasks that calculate a farmers market booth order
### order.h
Create a namespace called order
In that namespace define the following:
Constant called DISCOUNTEDRATE with the value of
const DISCOUNTEDRATE ;
Constant called NORMALRATE with the value of
const NORMALRATE ;
Function prototypes for the functions described in the next part.
### order.cpp
Make sure to add any necessary header files and scope the functions back to the order namespace.
#### Function : Print the customers menu.
Call this function CustomerMenu It should not return anything or take any parameters.
The customer menu should look like this:
bash
Straweberry Booth Menu
Please choose from the following options:
Fresh Strawberries $
Strawberry Jam $
Glazed Strawberry Scone $
Chocolate Covered Strawberry $
Hint: Use the t character to get even spacing upon output
#### Function : Calculate price with tax
Function Setup
Named CalculateTax
Returns a double
Accepts two parameters.
The first parameter is a double and represent the price of a product.
The second parameter is a double and will represent the tax rate.
This parameter should have a default value of notice this is the value from our constant called NORMALRATE
Function Task
Calculate the tax based on the price and rate
Add tax to initial price
return the final result
Example:
If the price of an item were $ and the tax rate for that item were Then the function would first calculate the tax for the item: $
Then add that tax to the price, making it $
#### Function : Calculate price based on quantity
Function Setup
Named CalculatePrice
Returns a double
Accepts two parameters
The first parameter is a double and represents the price of the item
The second parameter is a double and represents the quantity of items
Function Task
Calculate the price of the item based on it's quantity
Example:
If the price of the item is $ and the user would like a quantity value of the total for that item would be $
#### Function : Update the total
Function Setup
Named UpdateTotal
Returns nothing
Accepts two parameters
The first parameter is a double and represents the new value to be added to the total
The second parameter is a double and is a reference to the total variable. This variable keeps track of the customer's running total.
Function Task
Update the passed in variable that is managing the customer's final total
Example:
If the total variable originally held the value of $ but the customer added a new amount of $ to their order, this function would update the total value to $
## Customer Order Flow
The customer's order flow will be handled in the maincpp file.
It should use the functions from the order namespace to calculate and present the final order total to the cashier.
### Main.cpp
Create the flow of the customer's order in maincpp by doing the following.
Print the menu
Get the users choice using the numbers from the menu ex: is for strawberries, etc
Use a switch statement to:
Calculate the products price with tax remember the business rules described in the introduction
Get users choice of item quantity
bash
For strawberries ask
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
