I am trying to write a function that will read an array of numbers with the count of the numbers. I want to take the numbers and assign them to letters.Then print out the counts of A's, B's,C's,D's and F's. What i have isnt finished but im really frustrated with what i have so far. Just need some guidance...thank you
this is the scale for the grades:
100-90 A
89-80 B
79-70 C
69-60 D
50-0 F

const int MAXSIZE=10;

double Averages[MAXSIZE]={80.2,95,60,49.5,77.8,87.9,99.9,29,76.1,92.5}
char lettergrades[MAXSIZE]={'B','A','B','C','F','D','B','A','A','B'}

//function call

//function definition

void countletterGrade(double NAverage, int count)

for (int=index; Naverage<index; index++)
7 Years
Discussion Span
Last Post by bimoweemo

First you need an array of averages, as you have already coded on line 3. You will eventually want to read those values from a data file and put them into an array, but hard-coding them for now will be ok so that you can finish the rest of the assignment.

The array of grades on line 4 is not needed. Instead, you need an array of 5 integers that will contain the count of letter grades. So if you declare int counts[5] = {0}; , counts[0] is for 'A', counts[1] = 'B', etc.

In a loop for each average, use a series of if statements to determine which grade is appropriate for the given average, then increment the counter element. For example

if( Averages[i] >= 90.0 ) counts[0]++;
else if( Averages[i] >= 80.0) counts[1]++;

Edited by Ancient Dragon: n/a


Thank you so much that fixed it...i appreciate your help.thank you!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.