Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ You are the owner of a pawnshop. Each and everyday you sell a number of i

ID: 3813361 • Letter: I

Question

In C++ You are the owner of a pawnshop. Each and everyday you sell a number of items. At the end of the day you wish to know what your net profits are during the day. The gross profit is computed as the difference between the selling price and the price you paid for the item. To calculate the net profit you subtract 6% of the selling price from the gross profit and subtract 10% of the selling price for overhead. The resulting value is the net profit. Your program will read in the record of sales for the day. For each product sold there will be a record of sales for that product. We don’t know how many products were sold. The program will read in the name of the item, the actual cost of the item, and the number of this item that sold. Following this there will be data for each of this type of item. It will consist of the selling price for the item that was sold. When the program reads all of the data for an item it is to calculate the gross profit and net profit as described previously. The program is to output the name of the item, followed by the gross profit for the item, followed by the net profit for the item. The table is to be neatly displayed and money values should look like money. After this display the program will read the next item sold or it will read the word “fine” meaning that there are no more items sold to process. All of the tasks written for the program should be written as functions. The main function calls these functions to carry out the work of the program (Remember, functions can call other functions). The main program should do NO INPUT, and NO OUTPUT. No global variables may be used.

Explanation / Answer

Here overhead condition is not mentioned.Please tell me how to add that in comment section.I will update the code.thanks

#include<iostream>
using namespace std;
//calculate gross profit
double calculate_GP(double *selling_price,double actual_cost,int size_arr)
{
double sum=0.0;
for(int i = 0; i < size_arr; i++)
{
sum += (selling_price[i] - actual_cost);
}
return sum;
}
//calculate net profit
double calculate_NP(double *selling_price,double gross_profit,int size_arr)
{
double sum = 0.0;
//Here we have to add logic for overhead.In this overhead condition is not mentioned so check that condition
//and update in comment section.I will add the code for same
for(int i = 0; i < size_arr; i++)
{
sum += (gross_profit- (0.06 *selling_price[i]));
}

return sum;
}
//display data of product
void display_data(string item_name,double gross_profit,double net_profit)
{
//here you can change the currency,I added dollar $

cout<<"Item Name: "<<item_name<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"Gross Profit: $"<<gross_profit<<endl;
cout<<"Net Profit : $"<<net_profit<<endl;
}
int main()
{
string name_of_item;
double actual_cost;
int units_sold;
double gross_profit,net_profit;
double *selling_price;

string choice;

do
{
cout<<"Enter Name of item : ";
cin>>name_of_item;


cout<<" Enter Actual cost of item : ";
cin>>actual_cost;

cout<<" Enter number of this items sold : ";
cin>>units_sold;
selling_price = new double(units_sold);
cout<<"Enter selling price of the items below one by one"<<endl;

for(int i = 0; i < units_sold; i++)
{
cin>>selling_price[i];
}
//calculating gross profit
gross_profit = calculate_GP(selling_price,actual_cost,units_sold);
net_profit = calculate_NP(selling_price,gross_profit,units_sold);

display_data(name_of_item,gross_profit,net_profit);

cout<<" Do you want to continue : 'yes' to continue and 'fine' to stop"<<endl;
cin>>choice;
}while(choice.compare("fine"));
}

please refer below output

Enter Name of item : Soap

Enter Actual cost of item : 20.50

Enter number of this items sold : 6
Enter selling price of the items below one by one
25
23.5
22.5
21.5
24
23.5
Item Name: Soap
------------------------------------------------------
Gross Profit: $17
Net Profit : $93.6


Do you want to continue : 'yes' to continue and 'fine' to stop
fine

Process returned 0 (0x0) execution time : 211.054 s
Press any key to continue.