Question: For this lab, you will be writing two functions. The first function requires that you use pass-by-reference or call-by-reference. The second function requires that you

 For this lab, you will be writing two functions. The first
function requires that you use pass-by-reference or call-by-reference. The second function requires
that you pass the data using pointers. *Note: the address above requires

For this lab, you will be writing two functions. The first function requires that you use pass-by-reference or call-by-reference. The second function requires that you pass the data using pointers. *Note: the address above requires a trailing period** For this lab, we are an ambitious gold artisan. We buy pieces of gold and then make them into jewelry and resell them on Etsy. We start with $500 as starting cash. We are going to buy pieces of gold which cost $25.50 for each piece. We then craft one piece of jewelry for each piece of gold. We sell the jewelry for $55 for each piece. Using pass-by-reference, create a void function called buxgold that takes in two parameters and asks the user how much gold they want to purchase. This function reduces our cash and increases how much gold we have. . Using pointers (not pass by reference!), create another void function called sell Geld that takes in two parameters and sells the jewelry. This function decreases gold and increases cash. . You will need to create global constants for initial cash (500), gold cost ($25.5), and the gold sell ($55) Make sure to include validation quantities (do not exceed cash or gold) and print an error messages when needed. You do not need to validate data types (assume user will input an integer). For quantity issues use something like: "Cannot buy that much gold" or "You don't have enough gold to sell. Your current cash amount is $500.00 You have 0 pieces of gold. How many pieces of gold would you like to purchase? 21 Cannot buy that much gold! How many pieces of gold would you like to purchase? 19 You bought 19 pieces of gold and your current cash is $15.50 How much gold would you like to sell? 20 You don't have enough gold to sell. How much gold would you like to sell? 19 You sold 0 pieces of gold. Current Cash: $1060.50 Current Gold: 0 #include using namespace std; 1/Constants here cash = 500, buy for $25.50, sell for $55 1/Function Prototypes (Two functions - buyGold(reference) and sellGold (pointers)) int main() { double cash - START_CASH; //Your starting cash int gold - 0; // Your starting gold //Display initial message cout.precision (2); //Sets precision for currency 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!