Question: 1. Add on to your taqueria program from exercise A (PROGRAM BELOW): just like in todays slides, create a new struct named Cost which contains

1. Add on to your taqueria program from exercise A (PROGRAM BELOW): just like in todays slides, create a new struct named Cost which contains two floats: wholesale and retail. Add one of these to the your SalesRecord struct, so it now has three fields the name, the number sold, and the Cost struct. Modify your input loop to input both wholesale and retail costs for each burrito type.

2. Write a function which takes a SalesRecord as a parameter (by value), and returns the total profit from selling all the burritos of this type (unitProfit = retail - wholesale; totalProfit = unitProfit * numSold). float getProfit(SalesRecord record);

3. Write another function which steps through your array of SalesRecords and prints out the total profit for all burritos sold. You can do this by passing your function a pointer to the first element of your array and the number of elements in the array. The function can have a loop which will call getProfit() for each SalesRecord. void printReport(SalesRecord* records, int size);

#include

#include

#include using namespace std;

struct salesRecord { string bname; int bcount; };

int main() { int n; int k = 0; int total = 0;

cout << "Enter the number of different types sold: "; cin >> n;

salesRecord *arr = new salesRecord[n];

for(int i = 0; i < n; i++) { cout << "Enter the name of the burrito " << (i + 1) << ": "; cin >> arr[i].bname;

cout << "Enter the number of burritos sold of this type: "; cin >> arr[i].bcount;

total += arr[i].bcount; }

cout << endl << left << setw(15) << "Burrito_Name" << right << setw(15) << "Burrito_Count" << endl; cout << "------------------------------------------" << endl;

for(int i = 0; i < n; i++) { cout << left << setw(15) << arr[i].bname << right << setw(15) << arr[i].bcount << endl; } cout << "The total number of burritos sold for " << n << " types: " << total << endl;

}

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!