[C++] evaluating each set of inputs from the loop

Results 1 to 6 of 6
  1. #1
    Elite Member KillerNeedle is offline
    Member +Rank
    Nov 2007 Join Date
    197Posts

    [C++] evaluating each set of inputs from the loop

    ahh i have a question on for loop

    this is for a class so we have to do it using that . any ways the problem is enter the # of courses, credit, and grade.
    i am wondering how to evaluate each set of inputs in from the loop. for ex if course 1 the person had a b and it was worth 4 credits. and course 2 he got a c and its worth 5 credits. how would i be able to seperate each of the inputs so that i can calculate how much grade points each of the courses r worth.

    sorry if all this is a mess.


  2. #2
    Elite Member Smitty is offline
    Member +Rank
    Nov 2004 Join Date
    Kingston, ONLocation
    150Posts

    Re: C++ Need help

    If they're entering a letter grade and you need it to convert to a number, first I would have parallel arrays -- one containing the letter and one containing the equivalent grade.

    Then, when looping through the list, add the corresponding index to to another array which can be used for tallying everything in the end.

  3. #3
    Elite Member KillerNeedle is offline
    Member +Rank
    Nov 2007 Join Date
    197Posts

    Re: C++ Need help

    i have the lettering grade converting in a if statement but the problem i am facing atm is that in the loop you r entering grades and credits for courses 1 threw x i am jus wondering how to distinguish each of those variables so that i can multiply ( grade x credit for courses 1 threw x)

    like grade x credit for courses 1
    grade x credit for courses 2
    grade x credit for courses 3


    if ( grade == 'F' )
    value = 0;
    else
    value = 'E' - grade;

  4. #4
    Elite Member Smitty is offline
    Member +Rank
    Nov 2004 Join Date
    Kingston, ONLocation
    150Posts

    Re: C++ Need help

    I'm sorry, I don't understand. I will need to see the logic of the program to find out exactly how you should do it.

    Step by step, how does the user enter the information? Is there only one grade per course?

    Also, it is usually best not to use conditional statements for something like converting grades. If there was, say, a new Z grade, you would need to add another conditional IF to your code, whereas if you use an array, you would simply append it to the array.

  5. #5
    offonline King Grub is offline
    Grand MasterRank
    Aug 2009 Join Date
    Spring fieldLocation
    3,303Posts

    Re: C++ Need help

    Off topic @
    Smitty how many coder laungages you know?

  6. #6
    Elite Member Smitty is offline
    Member +Rank
    Nov 2004 Join Date
    Kingston, ONLocation
    150Posts

    Re: C++ Need help

    Quote Originally Posted by PirateOwh View Post
    Off topic @
    Smitty how many coder laungages you know?
    I know enough, I guess. I am a web developer so I know quite a bit about web technologies, but I also dabble in application development so I know several mainstream languages (to varying degrees) such as C++, C, C#, Java (which is also used for web dev. so I am more competent in it), COBOL (Not that it is mainstream LOL), etc.


    Once you become adept at one language, finding your way around other languages is usually only a Google search away.



Advertisement