Thread: Input students score

  1. #31
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    The maximum and minimum should look this once is done, for maximum:
    Code:
    s1236 Bridges, Tony D 82.20 D
    For minimum:
    Code:
    s1012 Bennet, Anne D 56.20 P
    Here is all my code,

    Code:
    #include <fstream>
    #include <iomanip>
    #include <string>
    using namespace std;
    
    int main()
    {
      ifstream inFileDay;
      ifstream inFileEvening;
      ofstream outFile;
      
      string studentdayId;
      string studenteveningId;
      string givenname, surname;
      int score1, score2, score3, score4, score5;
      int studentcounter;
      double AverageDay, AverageEvening, largest = 0;
       
      
      inFileDay.open("studentsDay.txt");   
      inFileEvening.open("studentsEvening.txt");
      outFile.open("report_regular.txt");                                      
     
     outFile.setf(ios::fixed, ios::floatfield);
     outFile.setf(ios::showpoint);
     outFile<<setprecision(2);
    
     outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl; 
     
        while (!inFileDay.eof() )
        {
         
         inFileDay>>studentdayId;
         outFile<<studentdayId<<"  ";
         inFileDay>>givenname>>surname;
         outFile<<surname<<", ";
         outFile<<givenname<<" ";
         outFile<<"D ";
         
         inFileDay>>score1>>score2>>score3>>score4>>score5;
     
         AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
       
         outFile<<AverageDay<<"  ";
         outFile.setf(ios::right);
         
         if(AverageDay>=85 && AverageDay<=100)
           outFile<<"HD "<<endl;
         else if(AverageDay>=75 && AverageDay<=85)
           outFile<<"D "<<endl;
         else if(AverageDay>=65 && AverageDay<=75)
           outFile<<"Cr "<<endl;
         else if(AverageDay>=55 && AverageDay<=65)
           outFile<<"P "<<endl;
         else
           outFile<<"F "<<endl;
         
         studentcounter++;
         }
         
         while (!inFileEvening.eof() )
        {
         
         inFileEvening>>studenteveningId;
         outFile<<studenteveningId<<"  ";
         inFileEvening>>givenname>>surname;
         outFile<<surname<<", ";
         outFile<<givenname<<" ";
         outFile<<"E ";
         inFileEvening>>score1>>score2>>score3>>score4>>score5;
     
         AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
       
         outFile<<setw(2)<<AverageEvening<<" ";
         outFile.setf(ios::right);
         
         if(AverageEvening>=85 && AverageEvening<=100)
           outFile<<"HD "<<endl;
         else if(AverageEvening>=75 && AverageEvening<=85)
           outFile<<"D "<<endl;
         else if(AverageEvening>=65 && AverageEvening<=75)
           outFile<<"Cr "<<endl;
         else if(AverageEvening>=55 && AverageEvening<=65)
           outFile<<"P "<<endl;
         else
           outFile<<"F "<<endl;
         
         studentcounter++;
         }
    
    outFile<<endl<<"+++++Section 2 The Maximum+++++"<<endl<<endl;
    
    inFileDay>>score1>>score2>>score3>>score4>>score5;
         AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
         studentcounter++;
         {
          while (studentcounter<=23)
          {
                ++studentcounter;
                if (AverageDay > largest)
                AverageDay = largest;
                }
                outFile<<AverageDay<<endl;
                }
    } 
    
    while (!inFileEvening.eof() )
        {
         inFileEvening>>score1>>score2>>score3>>score4>>score5;
         AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
         studentcounter++;
         {
          while (studentcounter<=6)
          {
                ++studentcounter;
                if (AverageEvening > largest)
                AverageEvening = largest;
                }
                outFile<<AverageEvening<<endl;
                }
    }
    
     if (AverageDay > AverageEvening)
    {
    outFile << AverageDay <<endl;
    else
    outFile << AverageEvening <<endl;
    }
    The last part of the code is for maximum and I have not got the minimum yet.

  2. #32
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    again, fix your code formatting, and you'll see that some of your code isn't even in main()
    Code:
    while (!inFileEvening.eof() )
    {
         inFileEvening>>score1>>score2>>score3>>score4>>score5;
         AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
         studentcounter++;
         {
             while (studentcounter<=6)
             {
                ++studentcounter;
                if (AverageEvening > largest)
                AverageEvening = largest;
            }
            outFile<<AverageEvening<<endl;
        }
    }
    
    if (AverageDay > AverageEvening)
    {
        outFile << AverageDay <<endl;
    }
    else
    {
        outFile << AverageEvening <<endl;
    }
    ...and you still didn't fix those last brackets, so I did it for you... again.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #33
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    So how can I make it work to display max and min score?

  4. #34
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    ...you may want to fix the rest of your logic first... take this step by step... this is the output you get so far:
    Code:
    +++++Section 1 Student List+++++
    
    s1012  Bennet, Anne D 56.20  P 
    s1236  Bridges, Tony D 82.20  D 
    s2341  Butcher, Michael D 60.80  P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P 
    +++++Section  Student, 1 E 60.80 P
    and that goes on and on and on and on
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #35
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    How can I fix this?

  6. #36
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    nevermind that... I had a problem with the files on my system... updated output:
    Code:
    +++++Section 1 Student List+++++
    
    s1012  Bennet, Anne D 56.20  P 
    s1236  Bridges, Tony D 82.20  D 
    s2341  Butcher, Michael D 60.80  P 
    s5454  Sunshine, Joe E 78.40 D 
    s5466  White, Vanessa E 70.00 Cr 
    s5553  Sunder, Jim E 67.20 Cr 
    
    +++++Section 2 The Maximum+++++
    
    0.00
    67.20
    here's your final code:
    Code:
    #include <fstream>
    #include <iomanip>
    #include <string>
    using namespace std;
    
    int main()
    {
        ifstream inFileDay;
        ifstream inFileEvening;
        ofstream outFile;
    
        string studentdayId;
        string studenteveningId;
        string givenname, surname;
        int score1, score2, score3, score4, score5;
        int studentcounter;
        double AverageDay, AverageEvening;
        
        float maxscore&#091;2&#093;;
        float minscore&#091;2&#093;;
        
        for(int i=0;i<2;i++)
        {
            maxscore&#091;i&#093;=-1;
            minscore&#091;i&#093;=101;
        }
    
        inFileDay.open("Untitled1.txt");
        inFileEvening.open("Untitled2.txt");
        outFile.open("Untitled3.txt",std::ios::trunc);
    
        outFile.setf(ios::fixed, ios::floatfield);
        outFile.setf(ios::showpoint);
        outFile<<setprecision(2);
    
        outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl;
    
        while (!inFileDay.eof() )
        {
            inFileDay>>studentdayId;
            outFile<<studentdayId<<"  ";
            inFileDay>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"D ";
    
            inFileDay>>score1>>score2>>score3>>score4>>score5;
    
            AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
    
            outFile<<AverageDay<<"  ";
            outFile.setf(ios::right);
            
            maxscore&#091;0&#093;=(AverageDay>maxscore&#091;0&#093;?AverageDay:maxscore&#091;0&#093;);
            minscore&#091;0&#093;=(AverageDay<minscore&#091;0&#093;?AverageDay:minscore&#091;0&#093;);
    
            if(AverageDay>=85 && AverageDay<=100)
                outFile<<"HD "<<endl;
            else if(AverageDay>=75 && AverageDay<=85)
                outFile<<"D "<<endl;
            else if(AverageDay>=65 && AverageDay<=75)
                outFile<<"Cr "<<endl;
            else if(AverageDay>=55 && AverageDay<=65)
                outFile<<"P "<<endl;
            else
                outFile<<"F "<<endl;
    
            studentcounter++;
        }
    
        while (!inFileEvening.eof() )
        {
            inFileEvening>>studenteveningId;
            outFile<<studenteveningId<<"  ";
            inFileEvening>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"E ";
            inFileEvening>>score1>>score2>>score3>>score4>>score5;
    
            AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
            
            maxscore&#091;1&#093;=(AverageEvening>maxscore&#091;1&#093;?AverageEvening:maxscore&#091;1&#093;);
            minscore&#091;1&#093;=(AverageEvening<minscore&#091;1&#093;?AverageEvening:minscore&#091;1&#093;);
    
            outFile<<setw(2)<<AverageEvening<<" ";
            outFile.setf(ios::right);
    
            if(AverageEvening>=85 && AverageEvening<=100)
                outFile<<"HD "<<endl;
            else if(AverageEvening>=75 && AverageEvening<=85)
                outFile<<"D "<<endl;
            else if(AverageEvening>=65 && AverageEvening<=75)
                outFile<<"Cr "<<endl;
            else if(AverageEvening>=55 && AverageEvening<=65)
                outFile<<"P "<<endl;
            else
                outFile<<"F "<<endl;
    
            studentcounter++;
        }
    
        outFile<<endl<<"+++++Section 2 The Maximum+++++"<<endl<<endl;
        outFile<<"Day Max: "<<maxscore&#091;0&#093;
            <<"\nDay Min: "<<minscore&#091;0&#093;
            <<"\nEvening Max: "<<maxscore&#091;1&#093;
            <<"\nEvening Min: "<<minscore&#091;1&#093;<<std::flush;
        
        return 0;
    }
    Last edited by major_small; 04-29-2005 at 01:36 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #37
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    I need this to get it work, I have tried many different combination but no luck. What is the best way to show the max and min score?

  8. #38
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    ...what I gave you isn't good enough?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  9. #39
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    I just only need one maximum which is the 93.80, along with the studentId and name so do I just put the outFile studentID <<surname << givenname << D/E << 93.80 << grade <<endl;

    Does 93.80 recognise which student receive that mark?

  10. #40
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    in that case...
    Code:
    #include <fstream>
    #include <iomanip>
    #include <string>
    using namespace std;
    
    int main()
    {
        ifstream inFileDay;
        ifstream inFileEvening;
        ofstream outFile;
    
        string studentdayId;
        string studenteveningId;
        string givenname, surname;
        int score1, score2, score3, score4, score5;
        int studentcounter;
        double AverageDay, AverageEvening;
        
        float maxscore;
        float minscore;
        string maxSID;
        string minSID;
        string maxName;
        string minName;
    
        maxscore=-1;
        minscore=101;
    
        inFileDay.open("Untitled1.txt");
        inFileEvening.open("Untitled2.txt");
        outFile.open("Untitled3.txt",std::ios::trunc);
    
        outFile.setf(ios::fixed, ios::floatfield);
        outFile.setf(ios::showpoint);
        outFile<<setprecision(2);
    
        outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl;
    
        while (!inFileDay.eof() )
        {
            inFileDay>>studentdayId;
            outFile<<studentdayId<<"  ";
            inFileDay>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"D ";
    
            inFileDay>>score1>>score2>>score3>>score4>>score5;
    
            AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
    
            outFile<<AverageDay<<"  ";
            outFile.setf(ios::right);
            
            if(maxscore<AverageDay)
            {
                maxscore=AverageDay;
                maxSID=studentdayId;
                maxName=givenname+" "+surname;
            }
            if(minscore>AverageDay)
            {
                minscore=AverageDay;
                minSID=studentdayId;
                minName=givenname+" "+surname;
            }
    
            if(AverageDay>=85 && AverageDay<=100)
                outFile<<"HD "<<endl;
            else if(AverageDay>=75 && AverageDay<=85)
                outFile<<"D "<<endl;
            else if(AverageDay>=65 && AverageDay<=75)
                outFile<<"Cr "<<endl;
            else if(AverageDay>=55 && AverageDay<=65)
                outFile<<"P "<<endl;
            else
                outFile<<"F "<<endl;
    
            studentcounter++;
        }
    
        while (!inFileEvening.eof() )
        {
            inFileEvening>>studenteveningId;
            outFile<<studenteveningId<<"  ";
            inFileEvening>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"E ";
            inFileEvening>>score1>>score2>>score3>>score4>>score5;
    
            AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
            
            if(maxscore<AverageEvening)
            {
                maxscore=AverageEvening;
                maxSID=studentdayId;
                maxName=givenname+" "+surname;
            }
            if(minscore>AverageEvening)
            {
                minscore=AverageEvening;
                minSID=studentdayId;
                minName=givenname+" "+surname;
            }
            
            outFile<<setw(2)<<AverageEvening<<" ";
            outFile.setf(ios::right);
    
            if(AverageEvening>=85 && AverageEvening<=100)
                outFile<<"HD "<<endl;
            else if(AverageEvening>=75 && AverageEvening<=85)
                outFile<<"D "<<endl;
            else if(AverageEvening>=65 && AverageEvening<=75)
                outFile<<"Cr "<<endl;
            else if(AverageEvening>=55 && AverageEvening<=65)
                outFile<<"P "<<endl;
            else
                outFile<<"F "<<endl;
    
            studentcounter++;
        }
    
        outFile<<endl<<"+++++Section 2 The Maximum+++++"<<endl<<endl;
        outFile<<"Max Score: "<<maxscore
            <<'\n'<<maxName<<" ("<<maxSID<<')'<<" is my best student."
            <<"\nMin Score: "<<minscore
            <<'\n'<<minName<<" ("<<minSID<<')'<<", you need to drop this class..."
            <<std::flush;
        
        return 0;
    }
    and your output:
    Code:
    +++++Section 1 Student List+++++
    
    s1012  Bennet, Anne D 56.20  P 
    s1236  Bridges, Tony D 82.20  D 
    s2341  Butcher, Michael D 60.80  P 
    s5454  Sunshine, Joe E 78.40 D 
    s5466  White, Vanessa E 70.00 Cr 
    s5553  Sunder, Jim E 67.20 Cr 
    
    +++++Section 2 The Maximum+++++
    
    Max Score: 82.20
    Tony Bridges (s1236) is my best student.
    Min Score: 56.20
    Anne Bennet (s1012), you need to drop this class...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  11. #41
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    Thanx, but how can it recognise whether the maximum and minimum score student is from day or evening. Because the expected output should look like this:
    For maximum:
    Code:
    s1236  Bridges, Tony D 82.20  D
    For minimum:
    Code:
    s1012  Bennet, Anne D 56.20  P
    As previously, I just typed in the "D" and "E" in the while loop. Do they need to change?

  12. #42
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Code:
    #include <fstream>
    #include <iomanip>
    #include <string>
    using namespace std;
    
    int main()
    {
        ifstream inFileDay;
        ifstream inFileEvening;
        ofstream outFile;
    
        string studentdayId;
        string studenteveningId;
        string givenname, surname;
        int score1, score2, score3, score4, score5;
        int studentcounter;
        double AverageDay, AverageEvening;
        
        float maxscore;
        float minscore;
        char maxTime='D';
        char minTime='D';
        string maxSID;
        string minSID;
        string maxName;
        string minName;
    
        maxscore=-1;
        minscore=101;
    
        inFileDay.open("Untitled1.txt");
        inFileEvening.open("Untitled2.txt");
        outFile.open("Untitled3.txt",std::ios::trunc);
    
        outFile.setf(ios::fixed, ios::floatfield);
        outFile.setf(ios::showpoint);
        outFile<<setprecision(2);
    
        outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl;
    
        while (!inFileDay.eof() )
        {
            inFileDay>>studentdayId;
            outFile<<studentdayId<<"  ";
            inFileDay>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"D ";
    
            inFileDay>>score1>>score2>>score3>>score4>>score5;
    
            AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
    
            outFile<<AverageDay<<"  ";
            outFile.setf(ios::right);
            
            if(maxscore<AverageDay)
            {
                maxscore=AverageDay;
                maxSID=studentdayId;
                maxName=givenname+" "+surname;
            }
            if(minscore>AverageDay)
            {
                minscore=AverageDay;
                minSID=studentdayId;
                minName=givenname+" "+surname;
            }
    
            if(AverageDay>=85 && AverageDay<=100)
                outFile<<"HD "<<endl;
            else if(AverageDay>=75 && AverageDay<=85)
                outFile<<"D "<<endl;
            else if(AverageDay>=65 && AverageDay<=75)
                outFile<<"Cr "<<endl;
            else if(AverageDay>=55 && AverageDay<=65)
                outFile<<"P "<<endl;
            else
                outFile<<"F "<<endl;
    
            studentcounter++;
        }
    
        while (!inFileEvening.eof() )
        {
            inFileEvening>>studenteveningId;
            outFile<<studenteveningId<<"  ";
            inFileEvening>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"E ";
            inFileEvening>>score1>>score2>>score3>>score4>>score5;
    
            AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
            
            if(maxscore<AverageEvening)
            {
                maxscore=AverageEvening;
                maxSID=studentdayId;
                maxName=givenname+" "+surname;
                maxTime='E';
            }
            if(minscore>AverageEvening)
            {
                minscore=AverageEvening;
                minSID=studentdayId;
                minName=givenname+" "+surname;
                maxTime='E';
            }
            
            outFile<<setw(2)<<AverageEvening<<" ";
            outFile.setf(ios::right);
    
            if(AverageEvening>=85 && AverageEvening<=100)
                outFile<<"HD "<<endl;
            else if(AverageEvening>=75 && AverageEvening<=85)
                outFile<<"D "<<endl;
            else if(AverageEvening>=65 && AverageEvening<=75)
                outFile<<"Cr "<<endl;
            else if(AverageEvening>=55 && AverageEvening<=65)
                outFile<<"P "<<endl;
            else
                outFile<<"F "<<endl;
    
            studentcounter++;
        }
    
        outFile<<endl<<"+++++Section 2 The Maximum+++++"<<endl<<endl;
        outFile<<maxName<<" ("<<maxSID<<", "<<maxTime<<") is my best student, with "
            <<"a score of "<<maxscore<<'\n'<<minName<<" ("<<minSID<<", "<<minTime
            <<"), you need to drop this class... you only got a "<<minscore
            <<std::flush;
        
        return 0;
    }
    Code:
    +++++Section 1 Student List+++++
    
    s1012  Bennet, Anne D 56.20  P 
    s1236  Bridges, Tony D 82.20  D 
    s2341  Butcher, Michael D 60.80  P 
    s5454  Sunshine, Joe E 78.40 D 
    s5466  White, Vanessa E 70.00 Cr 
    s5553  Sunder, Jim E 67.20 Cr 
    
    +++++Section 2 The Maximum+++++
    
    Tony Bridges (s1236, D) is my best student, with a score of 82.20
    Anne Bennet (s1012, D), you need to drop this class... you only got a 56.20
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  13. #43
    T-Mac wiz23's Avatar
    Join Date
    Apr 2005
    Location
    Houston
    Posts
    48
    Just one thing, I also need the grade at the end.

  14. #44
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Code:
    #include <fstream>
    #include <iomanip>
    #include <string>
    using namespace std;
    
    int main()
    {
        ifstream inFileDay;
        ifstream inFileEvening;
        ofstream outFile;
    
        string studentdayId;
        string studenteveningId;
        string givenname, surname;
        int score1, score2, score3, score4, score5;
        int studentcounter;
        double AverageDay, AverageEvening;
        string grade;
        
        float maxscore;
        float minscore;
        char maxTime='D';
        char minTime='D';
        string maxGrade;
        string minGrade;
        string maxSID;
        string minSID;
        string maxName;
        string minName;
    
        maxscore=-1;
        minscore=101;
    
        inFileDay.open("Untitled1.txt");
        inFileEvening.open("Untitled2.txt");
        outFile.open("Untitled3.txt",std::ios::trunc);
    
        outFile.setf(ios::fixed, ios::floatfield);
        outFile.setf(ios::showpoint);
        outFile<<setprecision(2);
    
        outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl;
    
        while (!inFileDay.eof() )
        {
            inFileDay>>studentdayId;
            outFile<<studentdayId<<"  ";
            inFileDay>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"D ";
    
            inFileDay>>score1>>score2>>score3>>score4>>score5;
    
            AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
    
            outFile<<AverageDay<<"  ";
            outFile.setf(ios::right);
    
            if(AverageDay>=85 && AverageDay<=100)
                grade="HD";
            else if(AverageDay>=75 && AverageDay<=85)
                grade="D ";
            else if(AverageDay>=65 && AverageDay<=75)
                grade="Cr";
            else if(AverageDay>=55 && AverageDay<=65)
                grade="P ";
            else
                grade="F ";
                
            outFile<<grade<<endl;
                
            if(maxscore<AverageDay)
            {
                maxscore=AverageDay;
                maxSID=studentdayId;
                maxName=givenname+" "+surname;
                maxGrade=grade;
            }
            if(minscore>AverageDay)
            {
                minscore=AverageDay;
                minSID=studentdayId;
                minName=givenname+" "+surname;
                minGrade=grade;
            }
    
            studentcounter++;
        }
    
        while (!inFileEvening.eof() )
        {
            inFileEvening>>studenteveningId;
            outFile<<studenteveningId<<"  ";
            inFileEvening>>givenname>>surname;
            outFile<<surname<<", ";
            outFile<<givenname<<" ";
            outFile<<"E ";
            inFileEvening>>score1>>score2>>score3>>score4>>score5;
    
            AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
            
            outFile<<setw(2)<<AverageEvening<<" ";
            outFile.setf(ios::right);
    
            if(AverageEvening>=85 && AverageEvening<=100)
                grade="HD";
            else if(AverageEvening>=75 && AverageEvening<=85)
                grade="D ";
            else if(AverageEvening>=65 && AverageEvening<=75)
                grade="Cr";
            else if(AverageEvening>=55 && AverageEvening<=65)
                grade="P ";
            else
                grade="F ";
                
            outFile<<grade<<endl;
                
            if(maxscore<AverageEvening)
            {
                maxscore=AverageEvening;
                maxSID=studentdayId;
                maxName=givenname+" "+surname;
                maxGrade=grade;
                maxTime='E';
            }
            if(minscore>AverageEvening)
            {
                minscore=AverageEvening;
                minSID=studentdayId;
                minName=givenname+" "+surname;
                minGrade=grade;
                minTime='E';
            }
    
            studentcounter++;
        }
    
        outFile<<"\n+++++Section 2 The Maximum+++++\n\n"
            <<maxName<<" ("<<maxSID<<", "<<maxTime<<") is my best student, with "
            <<"a score of "<<maxscore<<" ("<<maxGrade<<")\n"<<minName<<" ("<<minSID
            <<", "<<minTime<<"), you need to drop this class... you only got a "
            <<minscore<<" ("<<minGrade<<')'<<std::flush;
        
        return 0;
    }
    Code:
    +++++Section 1 Student List+++++
    
    s1012  Bennet, Anne D 56.20  P 
    s1236  Bridges, Tony D 82.20  D 
    s2341  Butcher, Michael D 60.80  P 
    s5454  Sunshine, Joe E 78.40 D 
    s5466  White, Vanessa E 70.00 Cr
    s5553  Sunder, Jim E 67.20 Cr
    
    +++++Section 2 The Maximum+++++
    
    Tony Bridges (s1236, D) is my best student, with a score of 82.20 (D )
    Anne Bennet (s1012, D), you need to drop this class... you only got a 56.20 (P )
    now that I did your work for you... I'm heading off to sleep because it's 5:28 AM and I have work in a few hours...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  15. #45
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    This looks a lot like homework to me

    http://cboard.cprogramming.com/annou...ouncementid=39

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting lowest and highest score from array
    By sjalesho in forum C Programming
    Replies: 6
    Last Post: 03-01-2011, 06:24 PM
  2. Input class project (again)
    By Elysia in forum C++ Programming
    Replies: 41
    Last Post: 02-13-2009, 10:52 AM
  3. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  4. fscanf in different functions for the same file
    By bchan90 in forum C Programming
    Replies: 5
    Last Post: 12-03-2008, 09:31 PM
  5. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM