I'm having a lot of issues with a program I'm working on and I really use any suggestions I could get. The purpose of the program is to take an input file that has a users name, the number of minutes in their call plan, and the number of minutes they actually used the month before. The programs calls for assigning a bonus number of minutes for the new month based on minutes used, and to output the name, minutes in plan, and amount of minutes for the new month. At the end it calls for the outputting of summary info; number of people with each call hour plan, total number of bonus hours awarded, average number of hours per user, and what i really need help with
the maximum and minimum number of hours used by the users
this is the first time I've tried using the set spaced char variable .. so im not sure if thats throwing off my inputs and outputs
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
main()
{
//definition of the variables for the program
ifstream infile;
ofstream outfile;
char name[15];
int planmin, usedmin, fivecount, thoucount, twothoucount, bonustotal, bonusmin, quotamin, quotatot, mintotal, users;
float average;
fivecount = 0;
thoucount = 0;
twothoucount = 0;
bonusmin = 0;
users = 0;
mintotal = 0;
bonustotal = 0;
//opening of the input and putput files
infile.open("Sell_U_R.dat");
if (infile.fail())
{
cout << "The input file cannot be located" << endl;
exit(1);
}
outfile.open("file_customer.out", ios::out);
if (outfile.fail())
{
cout << "The output file could not be created" << endl;
exit(1);
}
outfile << fixed << setprecision(0);
//while loop to read the
while(!infile.eof())
{
infile.getline(name, 15) >> planmin >> usedmin;
if (usedmin > 2000)
bonusmin = (planmin * 0.15);
else if (usedmin >= 1500 || usedmin <= 2000)
bonusmin = (planmin * 0.12);
else if (usedmin > 500 || usedmin < 1500)
bonusmin = (planmin * 0.10);
else if (usedmin == 500)
bonusmin = 1000;
if (planmin == 500)
fivecount++;
else if (planmin == 1000)
thoucount++;
else if (planmin == 2000)
twothoucount++;
quotamin = planmin + bonusmin;
quotatot+= quotamin;
users++;
mintotal+= usedmin;
bonustotal+=bonusmin;
outfile << name << setw(8) << planmin << setw(8)<< quotamin << endl;
}
average = mintotal / users;
outfile << endl;
outfile << "Number of 500 minute plans " << fivecount << endl;
outfile << "Number of 1000 minute plans " << thoucount << endl;
outfile << "Number of 2000 minute plans " << twothoucount << endl;
outfile << "Maximum number of minutes by a user " << endl;
outfile << "Minimum number of minutes by a user " << endl;
outfile << "Average minutes used ber user " << average << endl;
outfile << "Total Bonus Minutes given " << bonustotal << endl;
infile.close();
outfile.close();
system("pause");
return 0;
}