// salesreport.h
#include <iostream>
usingnamespace std;
class SalesReport
{ double grossSales;
public:
SalesReport()
{ setGrossSalesEqual(0);
}
void setGrossSalesEqual (double sale)
{ grossSales = sale;
}
double getGrossSales()
{ return grossSales;
}
int calculateSalary() // Requirement 2 says this should be an int function
{ return (int)(200 + (0.09 * grossSales));
}
}
//this method is where I'm am trying to get it access to main class below.
void salRange( int salary)
{
int bucket;
if (salary>=1000)
{
bucket=10;
}
else
{
bucket=salary/100;
}
range[bucket]++;
}
};
// main.cpp
#include <iostream>
#include <iomanip>
// #include "SalesReport.h"
usingnamespace std;
int main()
{ SalesReport theSales,money, display;
double sales;
int range[11]={0};
int salary;
//int bucket;// do I need this there?
cout << "Enter sales in dollars (-1 to end): ";
cin >> sales;
while (sales != -1)
{ theSales.setGrossSalesEqual(sales);
salary = theSales.calculateSalary();
cout << setprecision(2) << fixed;
cout << "Salary is: " << salary << endl;
// if(salary>=1000)
// {
// bucket=10;
// }
// else
// {
// bucket=salary;
range[bucket]++;
//}
money.salRange(salary); //
//The code for if and else statements is where I made them into a function in the salesreport class
cout << "\nEnter sales in dollars (-1 to end): ";
cin >> sales;
}
for (int i=2; i<=10; i++)
{
if (i == 10)
cout << "$1000 and over: " << range[i] << endl;
else
cout << "$" << i << "00-$" << i << "99: " << range[i] << endl;
}
return 0;
}
You haven't fixed the errors I pointed out to you via IM. Please try and correct all compile errors before posting your code. If you don't understand why you getting certain compile errors, then say so.
Line 23: Extraneous }
Line 36: range is undefined.
Line 70: bucket is undefined
The reason why you're printing all zeroes is that you're never updating the range array defined at line 52.
I told you before, put the range array in the class and make lines 77-83 a function member of the class.