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

I have a few errors to fix my c++ project to compile and be able to run like it

ID: 3849135 • Letter: I

Question

I have a few errors to fix my c++ project to compile and be able to run like it asks for, coding in either c++11 or c++14.

Prompt:

One large chemical company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9 percent of $5000, or a total of $650. Develop a C++ program that uses a while statement to input each salesperson’s gross sales for last week and calculates and displays that salesperson’s earnings. Process one salesperson’s figures at a time.

Requirements:

create 2 separate files for this homework assignment. The Sales.h file contains the class Sales. Then the main.cpp

program should have one member data named grossSales.

program should have a constructor, a get and a set member function for the data.

The result salaries must be displayed in 2 decimal places.

Sample run of what it should look like:

Enter sales in dollars (-1 to end):5000 //input

Salary is: 650.00 //output

Enter sales in dollars (-1 to end): 5678 //input

Salary is: 711.02 //output

Enter sales in dollars (-1 to end):-1

Here is what I have and I am having trouble fixing my errors or what I need to fill in:

cpp file:

#include

#include "Sales.h"

int getmember ()

{
   using std::cout;
   using std::cin;

cout<<"Enter sales In dollar(-1to end)";
int grosssales; //variable input
cin>>grosssales; //input

return grosssales;

}

int setmember (int grosssales)

{
   using std::cout;
   using std::cin;
   using std::endl;
   int initialsalary=200; //initial salary given
   int Salary=0;
double gross=0.09; //commision rate

while(grosssales>=1)
{
   if(grosssales==-1) //terminate if -1
   break;
Salary=initialsalary+(gross*grosssales); //calculation for total salary

salesCounter++; error->'salesCounter' not declared in this scope

cout<<"Salary is "<<Salary<<endl; //output the salary after each input


}
}

int main()

{

getmember();

setmember(grosssales); error->'grosssales' not declared in this scope

}

Sales.h:

class setmember
public:
{

unsigned int salesCounter=-1;

int initialsalary=200;

int getmember();

int setmember(grossales); error-> 'grosssales' has not been declared in this scope, return type specification for constructor invalid.

};

How do I fix these errors?

Explanation / Answer

Try changing your main function from this-

int main()
{
getmember();
setmember(grosssales);
}

to

int main()
{
setmember(getmember());
}

EXPLANATION

getmember() function is set to return an int i.e. grosssales. Inside your main function you are not saving the return value of getmember() function to any variable. To get grosssales inside main function you will have to catch grosssales that is being returned by getmember() function