Thread: Hey guys can i get some help please?

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    6

    Hey guys can i get some help please?

    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;
    }

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    How would you do it as a human?

    If I give you a list of numbers and tell you to find the biggest, how would you do it? Can you do it if I give you the numbers one by one, without writing them down?

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    6
    some type of of statement maybe with a variable to hold on to the largest one
    max = 0;
    large = 0;

    prevnum = 3
    prevnum = 7
    prevnum = 20

    if (max < prevnum)
    max = prevnum;

    but that will change eachtime the the loop repeats it has to hold onto the max?

    I just dont know

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    6
    no wait that workded i got it. thanks for makin my brain work threw it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thanks Guys...
    By frodonet in forum C Programming
    Replies: 0
    Last Post: 11-03-2007, 08:16 PM
  2. do you guys have...
    By enjoyincubus in forum C Programming
    Replies: 7
    Last Post: 10-31-2006, 10:14 PM
  3. Hello guys =)
    By carol.prime in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-22-2006, 10:25 AM
  4. Need your help guys :'(
    By Saarah in forum C Programming
    Replies: 24
    Last Post: 09-08-2006, 01:18 AM
  5. Hey guys, I'm new!
    By MrDoomMaster in forum C++ Programming
    Replies: 15
    Last Post: 10-31-2003, 05:47 PM