how to calculate grade average in c++...plez help me!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanie
    New Member
    • Mar 2008
    • 2

    how to calculate grade average in c++...plez help me!

    a student wants to know his grade average for the semester. the grades are give in letter grades with numeric equivalents. develop a solution to calculate a grade average given the letter grades(the grade average is is figured per unit of credit!)
    A=4.0
    B=3.0
    C=2.0
    D=1.0
    F=0.0
    use a trip value to stop the processing of the loop and case structure to find the grade points
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    That’s a very common beginner programming assignment. Did you have a question?

    Comment

    • hanie
      New Member
      • Mar 2008
      • 2

      #3
      Originally posted by oler1s
      That’s a very common beginner programming assignment. Did you have a question?
      but i dont know how to use case structure.can you give me an example of it

      Comment

      • dwurmfeld
        New Member
        • Mar 2008
        • 9

        #4
        Originally posted by hanie
        but i dont know how to use case structure.can you give me an example of it
        I will not solve it for you here, you need to learn how to use the many C++ references you have available. I looked up switch-case statement on Google using this query: " switch case statement +"C++" " and I got many pages of hits, most of which give a clear definition and usage for the switch-case statement.

        One of the references I found gives a good example:
        http://www.fredosaurus .com/notes-cpp/statements/switch.html

        The key to using a switch-case statement is the case values must be immutable (constants) and not variables. For example:

        Code:
        int age, mary;
        char can_vote = FALSE;
        
        switch (age) {
        case 16:
        case 15:
            break;
        case mary:    // illegal case conditional, cannot be a variable
            can_vote = TRUE;
            break;
        case 'Q':
            // the constant character Q was assigned to age
            break;
        default:
            break;
        } // end switch(age)
        The other mistake often made is forgetting to use the break statement between cases. In the example above, if age contained the value 16, control flow would fall into the statement for the case of 15, there was no break after the case to seperate them.

        If, after trying the examples easily found by searching for the switch-case reference you have specific questions, feel free to ask.

        Comment

        Working...