need help..URGENT!

This is a discussion on need help..URGENT! within the C++ Programming forums, part of the General Programming Boards category; Hi, one of my assignment is to sort the names and grades of the students. This should output after everything ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    need help..URGENT!

    Hi, one of my assignment is to sort the names and grades of the students. This should output after everything has been coded:

    If the data is as follows:

    Joe 45
    Jim 55
    Sam 90

    ...Then the output will be
    Jim 55
    Joe 45
    Sam 90

    There was 1 A
    There were 2 F's
    The highest grade was 90
    The lowest grade was 45

    and then...

    Sam 90
    Jim 55
    Joe 45


    final out put shoud be:

    There was 1 A.
    There were 2F's
    The highest grade was 90
    The lowest grade was 45.


    The names and grades are stored in a text file:

    Sam 90
    Joe 45
    Jim 55

    Here's I got so far..if you can help me do the above..please help ..

    void AlphaSort (Str names[], int count)
    {
    // Sorts the grades alphabetically
    }
    void GradeSort (int grades[], int count)
    {
    // Sorts the grades in descending order
    int i,j,temp,largest;
    for (i=0; i<count-1; i++)
    {
    largest=i;
    for (j=largest+1;j<count; j++)
    if (grades[j]>grades[largest]) largest=j;
    temp=grades[largest];
    grades[largest]=grades[i];
    grades[0]=temp;
    }
    }
    void GradeCount (int grades[], int count)
    {
    // Counts the number of A's, B's, C's, D's, and F's
    }
    void PrintAll (Str names[], int grades[], int count)
    {
    // Function created to test input, make sure file is read correctly.
    cout << "The file contains:"<<endl;
    for (int i=0; i<count; i++)
    cout << names[i] << '\t' << grades[i]<<endl;
    }
    int main(void)
    {
    Str names[40];
    int grades[40];
    char fn[256];
    cout << "Please enter a filename: ";
    cin >> fn;
    ifstream infile(fn);
    int i=0;
    while (!infile.eof())
    {
    infile >> names[i] >> grades[i];
    i++;
    }
    PrintAll(names,grades,i);
    GradeSort(grades,i);
    cout<<endl<<"The grades should be sorted now:"<<endl;
    PrintAll(names,grades,i);
    infile.close();
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    URGENT ANSWER!!:

    What is your question?

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is a map.

    Kuphryn

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2
    I thought i was clear...help me to solve the problem that I mentioned above ^^^. Hopefully anyone can...time is runnning out..

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Hi,

    This is a C++ board, not a "do my assignment for me" board. If you have a C++ question ask it.
    Last edited by 7stud; 04-19-2003 at 03:45 AM.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by webmasts
    I thought i was clear...help me to solve the problem that I mentioned above ^^^. Hopefully anyone can...time is runnning out..
    No one is going to do your homework for you, because quite frankly, no one gives a $$$$ if you fail. If you have a specific question, then ask, and we'll be more than happy to answer. Otherwise, you're out of luck.

    [edit]Curses, foiled again![/edit]

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. display character size...(quite urgent..)
    By karthi in forum C Programming
    Replies: 10
    Last Post: 07-11-2007, 10:42 PM
  2. beginner plzz help urgent
    By sara101 in forum C Programming
    Replies: 11
    Last Post: 01-14-2007, 10:38 PM
  3. Linked List Need Help Urgent
    By ykchua in forum C Programming
    Replies: 5
    Last Post: 08-17-2004, 03:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21