can anyone here figure out my problem in my code
it reads from a dat file containing this.
when it creates the out put file it looks like thisCode: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
the problem is that the very first quota that is printed to the outfile is some random number and the last quota that is suppose to be printed isnt there. I don't know where the number came from. Can i please get some help this is due at 10 pm tonight!!!!.Code:Number of Minutes Customer Base Plan Used/Previous Month Quota C. Moore 1000 1250 4068584 Dot Net 2000 2075 1125 Hop Tuit 500 2873 2311 Jack B. Nimble 2000 824 931 Ron Ray Gunn 1000 2000 2082 Ura Winter 1000 500 1240 Summer Place 2000 1500 2000 Amber Reys 500 758 2180 Knot Wright 500 371 576 Moore Wright 1000 1234 500 Seymour Moore 500 500 1123
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, quota; char custmr; int loopcnt, max, min, bonus; 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 <<setw(2) << bsplan << setw(12) << useprevmonth << setw(25) << quota << endl; monthaccum += useprevmonth; // if (useprevmonth > 2000) {bonus = (useprevmonth * .15) + .5; quota = (bsplan + bonus); } else if (useprevmonth >= 1500 && useprevmonth <= 2000) {bonus = (useprevmonth * .12) + .5; quota = (bsplan + bonus); } else if (useprevmonth > 500 && useprevmonth < 1500) {bonus = (useprevmonth * .10) + .5; quota = (bsplan + bonus); } else if(useprevmonth < 500) {quota = bsplan;} else if (useprevmonth == 500) { bonus = 1000; quota = (bsplan + bonus); } infile.get(custmr); infile.get(custmr); } outfile << "\n\n"; infile.close(); outfile.close(); system ("pause"); return 0; }
THANK YOU



LinkBack URL
About LinkBacks


