I'm doing a project and I'm kind of stuck. The text file prog3a.txt is a file like this:
4
MBanner 35 35 35 35 35 35 35 35 34 35 35 35 36
BHunter 40 20 40 70 35 45 78 34 56 73 15 41 55
GJorgensen 60 62 47 68 40 53 62 88 18 15 72 12 19
TSmith 25 66 32 41 89 27 25 29 33 54 27 32 45
number of salesmen
name, quota, 12 months sales
and i need to:
- read in the number of salespeople
- read in the quota for that salesperson
- read in 12 actual monthly sales counts for that salesperson
- determine number of months the salesperson did or did not meet quota
- decide whether a campaign should be mounted
- identify the worst salesperson for meeting quotas
I know the text formatting is off too but I can worry about that after I find out what I'm doing wrong. Help with how to input data from the file correctly would be appreciated, anything else i can figure out on my own
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <conio.h>
using namespace std;
int main()
{
int totSalesperson;
int quota;
int salesCount;
int monthsMissed;
int quotasMissed;
int monthQuota;
int months;
int worst;
string salesPerson;
string worstSalesperson;
const int MAX_FAIL = 20;
ifstream ifile("prog3a.txt");
if(!ifile)
{
cout<< "Can't find source file";
_getch();
return 1;
}
ifile >> totSalesperson;
cout << "Total number of salesPeople: " << totSalesperson << endl;
cout << endl << "Salesman\t\tQuota\tMonthly Sales" << endl;
for (salesCount = 0; salesCount < totSalesperson; ++salesCount)
{
ifile >> salesPerson >> quota >> months;
cout << endl << salesPerson;
cout << quota << "\t" << months << monthsMissed << monthQuota;
monthsMissed = 0;
worst = 0;
if (months < quota)
{
monthsMissed = monthsMissed + 1;
}
cout << months;
cout << monthsMissed;
monthQuota = 12 - monthsMissed;
if (monthsMissed > 0)
{
quotasMissed = quotasMissed + 1;
}
if (monthsMissed > worst)
{
salesPerson = worstSalesperson;
quotasMissed = worst;
}
}
if ((quotasMissed * 100 / totSalesperson) > MAX_FAIL)
{
cout << "Sales campaign should be mounted";
}
else;
cout << "Good work";
cout << "Consider firing: " << worstSalesperson << "\n Program complete!";
_getch();
return 0;
}
|