Thread: I need help plzz :(

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    9

    Unhappy I need help plzz :(

    We have 20 Students from different levels (4290**** , 4280**** , 4270**** , 4260****) Every ID will start with one of those numbers .. (The ID cosist of 8 digits )
    And their Grades in 1 subject..

    It is supposed to print :

    1- Students ID and their Grades.

    2- Student ID that got the highest grade and the lowest grade and their and the ID Second two numbers starting from the left for the two students.

    3- The number of students got grades equal to Average or higher.

    4- The number of students got grades smaller than the Average.

    5- The number os Students from each Level .

    This is the program I wrote :

    Code:
    #include <iostream>
    #include <conio>
    
    
    void main()
    {
    int numberOfStudents [20] ;
    int score[100];
    char grade;
    int ID ;
    int i , j ;
    
    for( i=0 ; i<20 ;i++)
    {
        cout << "Enter Student "  << (i+1) << "  ID " ;
       cin>> ID;
       cout<< "Enter the score ";
       cin>>score[j];
    
    for( j=0;j<20;j++)
        {
        if(score[j]>=90)
            grade='A';
        else if(score[j]>=80)
            grade='B';
        else if (score[j]>=70)
            grade='C';
        else if (score[j]>=60)
            grade='D';
        else
            grade='F';
         }
      }
        cout<<"Student "<<(i+1)<<" score is = "<<(score[j])
        <<" and grade assigned is "<<grade<<endl;
    
      getch ();
    }
    I don't know how to complete it .. ><
    Any Help would be Gratefully Appreciated !!

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,337
    Your use of variable j in this segment of code is incorrect:
    Code:
    for( i=0 ; i<20 ;i++)
    {
        cout << "Enter Student "  << (i+1) << "  ID " ;
       cin>> ID;
       cout<< "Enter the score ";
       cin>>score[j];
    . . .
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,337
    Also, you have 20 students and 100 scores. Why?
    Mainframe assembler programmer by trade. C coder when I can.

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    68
    Where are you suppose to get the grades from? are you inputting them from a file?

    Do you have AIM or anything to chat. I have some extra time right now if you need help

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    17
    correct your code
    this is for the first part

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int ID [20];
        int score [20];
        int i,j;
    
    
        for (i=0;i<20;i++)
        {
            cout<<"Enter Student "<< i+1<< " ID: "<<endl;
            cin>> ID[i];
            cout<<"Enter Studet " << i+1<< "score: "<<endl;
            cin>> score[i];
        }
        for(j=0;j<20;j++)
        {
            if (score[j]<=100 && score[j]>=90)
            cout<<ID[j]<< "got " <<'A'<< endl;
            else
            if (score[j]<90 && score[j]>=80)
            cout<<ID[j]<< "got " <<'B'<<endl;
            else
            if (score[j]<80 && score[j]>=70)
            cout<<ID[j]<< "got " <<'C'<<endl;
            else
            if (score[j]<70 && score[j]>=60)
            cout<<ID[j]<< "got " <<'D'<<endl;
            else
            if (score[j]<60)
            cout<<ID[j]<< "got " <<'F'<<endl;
        }
    
        return 0;
    }
    Last edited by ladybird__86; 11-05-2009 at 06:48 PM.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    17
    *to calculate the average:
    in the first for loop sum+=score[i];

    then in the end of the program

    float Avg= sum/20;
    cout<<"average = "<<Avg;

    *for the lowest and highest:
    declared a new variables
    low=score[0];
    high=score[0];

    then make another for loop

    Code:
    for(int n=1; n<20; n++)
    {
          if ( score[n]>low) 
          low=score[n];
          if (score[n]<high)
          high=score[n];
    }
    i hope it is will help u... and if u have any question u are more than welcome...

  7. #7
    Registered User
    Join Date
    Sep 2009
    Posts
    68
    ladybird we want people to try to solve the problem on their own. We do not want to simply tell them what to do, they will never learn this way. And I'm assuming this is homework so we are not here to do homework for people.

    and if nothing else explain why he needs to be making these changes so he can understand on a logical level how they work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. plzz need help with remove() method
    By babyray in forum C++ Programming
    Replies: 2
    Last Post: 05-09-2009, 10:34 AM
  2. help me out plzz!!
    By salmanriaz in forum Game Programming
    Replies: 11
    Last Post: 03-20-2009, 09:56 AM
  3. beginner plzz help urgent
    By sara101 in forum C Programming
    Replies: 11
    Last Post: 01-14-2007, 10:38 PM
  4. Plzz help problem with strings
    By UltimoFX in forum C Programming
    Replies: 5
    Last Post: 04-14-2003, 08:06 PM
  5. need help , plzz
    By kfatima in forum C Programming
    Replies: 1
    Last Post: 10-11-2002, 09:19 PM