Im new to c++ and have a question that i hope yall can help
basically my file opens a file then extracts a list of names and numbers
here is whats in the inputfile
C. Moore 1000 1250
Dot Net 2000 2075
Hop Tuit 500 2873
Jack B. Nimble 2000 824
Ron Ray Gunn 1000 2000
Ura Winter 1000 500
Summer Place 2000 1500
Amber Reys 500 758
Knot Wright 500 371
Moore Wright 1000 1234
Seymour Moore 500 500
my program creates a outpout file named McKe_customer.out
in my outputfile i must give the max, min, and average, of minutes used in the previous month(THE SECOND NUMBER IN THE INFILE)and how many of the 500, 1000, and 2000 baseplans are in the the file(THE FIRST NUMBER OF THE INFILE) but i think i can figure that out one if i spend more time thinking about it.
i have the average done by just using a accumulater and using simple math but i am having trouble figuring out how to find the others.
HERE IS MY CODE
Please help!!!
thanks guys
Code:
// Damien McKeown
// PROGRAM 9
// CSC 101
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
int bsplan, useprevmonth, monthaccum = 0;
float quota;
char custmr;
int loopcnt, max, min;
float average ;
//open input file
infile.open("Sell_U_R.dat", ios::in);
//open output file and set flags
outfile.open("McKe_customer.out");
outfile << setw(30)<< "Number of Minutes\n";
outfile << "Customer" << setw(13) << "Base Plan" << setw(25) << "Used/Previous Month" << setw(11) << "Quota\n\n";
// loop to read till end of file
infile.get(custmr); // priming read
while (infile) // eof -controlled loop
{
outfile << custmr;
loopcnt = 1;
while (loopcnt <= 15)
{ infile.get(custmr);
outfile << custmr;
loopcnt++;
}
infile >> bsplan >> useprevmonth;
outfile << bsplan << " " << useprevmonth<< endl;
monthaccum += useprevmonth;
infile.get(custmr);
infile.get(custmr);
}
outfile << "\n\n";
outfile << "NUMBER OF 500 PLANS" << endl;
outfile << "NUMBER OF 1000 PLANS" << endl;
outfile << "NUMBER OF 2000 PLANS" << endl;
outfile << "THE MAX IS " << endl;
outfile << "THE MIN IS " << endl;
monthaccum = (monthaccum / 11);
outfile << "The average of last months used minutes is " << monthaccum;
infile.close();
outfile.close();
system ("pause");
return 0;
}