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

C++: Linda is starting a new cosmetic and clothing business and would like to ma

ID: 640846 • Letter: C

Question

C++: Linda is starting a new cosmetic and clothing business and would like to make a net profit of approximately 10% after paying all the expenses, which include merchandise cost, store rent, employee's salary, and electricity cost for the store. She would like to know how much the merchandise should be marked up so that after paying all the expenses at the end of the year she gets approximately 10% net profit on the merchandise cost. Note that after marking up the price of an item she would like to put the item on 15% sale. Write a program that prompts Linda to enter the total cost of the merchandise, the salary of the employees (including her own salary), the yearly rent, and the estimated electricity cost. The program the outputs how much the merchandise should be marked up so that Linda gets the desired profit.

Explanation / Answer


#include <iostream>

using namespace std;

const int NO_OF_MONTHS = 12;

void getData(int twoDim[][2], int rows);
int averageHigh(int twoDim[][2], int rows);
int averageLow(int twoDim[][2], int rows);
int indexHighTemp(int twoDim[][2], int rows);
int indexLowTemp(int twoDim[][2], int rows);

int main()
{
int hiLowArray[NO_OF_MONTHS][2];

int indexHigh;
int indexLow;

getData(hiLowArray, NO_OF_MONTHS);

cout << "Average high temperature: "
<< averageHigh(hiLowArray, NO_OF_MONTHS) << endl;
cout << "Average low temperature: "
<< averageLow(hiLowArray, NO_OF_MONTHS) << endl;

indexHigh = indexHighTemp(hiLowArray, NO_OF_MONTHS);
cout << "Highest temperature: " << hiLowArray[indexHigh][0] << endl;

indexLow = indexLowTemp(hiLowArray, NO_OF_MONTHS);
cout << "Lowest temperature: " << hiLowArray[indexLow][1] << endl;

return 0;
}

void getData(int twoDim[][2], int rows)
{
int i;

cout << "Enter high temperature for each month" << endl;

for (i = 0; i < rows; i++)
cin >> twoDim[i][0];

cout << "Enter low temperature for each month" << endl;

for (i = 0; i < rows; i++)
cin >> twoDim[i][1];
}

int averageHigh(int twoDim[][2], int rows)
{
int i;
  
int sum = 0;

for (i = 0; i < rows; i++)
sum = sum + twoDim[i][0];

if (rows > 0)
return sum / rows;
else
return 0;
}

int averageLow(int twoDim[][2], int rows)
{
int i;
  
int sum = 0;

for (i = 0; i < rows; i++)
sum = sum + twoDim[i][1];

if (rows > 0)
return sum / rows;
else
return 0;
}

int indexHighTemp(int twoDim[][2], int rows)
{
int i;
  
int highIndex = 0;

for (i = 1; i < rows; i++)
if (twoDim[highIndex][0] < twoDim[i][0])
highIndex = i ;

return highIndex;
}

int indexLowTemp(int twoDim[][2], int rows)
{
int i;
  
int lowIndex = 0;

for (i = 1; i < rows; i++)
if (twoDim[lowIndex][1] > twoDim[i][1])
lowIndex = i ;

return lowIndex;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote