Use an array to store the grades. Use a looping structure to populate the array. Calculate the numeric average based upon the 4 equally-weighted numeric grades. Display each of the 4 numeric grades from the array on the screen using a looping structure. Display the numeric average. Create a function that will convert the numeric average to a letter grade average using the grading scale: A = 90 to100 B = 80 to 89 C = 70 to 79 D = 60 to 69 F = Below 59 The function must return the value of the letter grade average. Display the letter grade average. Include comments At the top of the program to include: Your name Class name and number Instructor name Overall Description of program Comment each section of code Describe what the section accomplishes'

Recommended Answers

All 12 Replies

Why are you confused? What have you done? What have you considered? What are you having problems with? Did you try anything before running for help?

Simply posting your homework problem with no other substance is not only frowned upon here, it's actually against Daniweb rules.

im not just postign homework without doing it im attempting it just get confused with the right code. im still working on it i was going to post what i have been working on

im still working on it i was going to post what i have been working on

Cool. We'll wait. :)

it will not let me load it because of this message The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or curly braces.

// Program Name: Grade Average Program
// Purpose: Finding the grade average
// Author: Kearra Crawford
// Last modified: 27-Apr-2015


    // Declare variables
    gradNumber[4]; // 4 array slots
    int count;
    gradNumber total = 0;  // Set to 0 so total will start with 0 before calculating average.
    double average;  // Average will be display in decimal
 for (count = 1; count <= 4; count++) // Will display number 1-4 (++) will increase each number.
`    {`
        int << "Enter grade ";

        int >> grade[count]; // Output of grade entered with the number increasing 1
       ` }` //End of count grade

    } //End of array

   // Display gradNumber array
   gradNumber[0] =94
   gradNumber[1] =88
   gradNumber[2] =80
   gradNumber[3] =95




    cout << "You have entered the following grades: " << grade 0 + grade 1 + grade 2 + grade 3 << endl; 


    for(count = 1; count <= 4; count++) //Starting with number 1. 
        total = total + grade[count];
    average = total/4;
    cout << "Your average of four grades are: " << average << endl; //Output of average

so how is it am i on the right track can anyone help me?

i also get stuck on turning it in to a javascript. so can i get help with that as well?

There are a couple of pieces you've got a pretty good handle on, but what would be helpful now, is to show your entries and what the program yields thus far. I assume your entries are 94 "A", 88 "B", 80 "B" & 95 "A". Might be a good idea to make one of these a failing grade, let's say 45 "F" to prove your formula works.

1: There is a problem with lines 8 & 10.
2: Loops need to be zero indexed

for (count=0; count < 4; count++)

3: Why have you chosen average to be a double?
4: Variables in line 30 need be declared and can't contain white space. You've also done the same thing in line 10.

what do you mean by white space

I made changes do i still have problems?

// Program Name: Grade Average Program
// Purpose: Finding the grade average
// Author: Kearra Crawford
// Last modified: 27-Apr-2015


    // Declare variables
    gradNumber;      // array slots
    int count;
    gradtotal=0;  // Set to 0 so total will start with 0 before calculating average.
    average;      // Average will be display in decimal
    for (count = 0; count <= 4; count++) // Will display number 1-4 (++) will increase each number.
    {
        count << "Enter grade " << count << ": ";
        {
        int >> grade[count]; // Output of grade entered with the number increasing 1
        } //End of count grade

    } //End of array

   // Load gradNumber array
   gradNumber[0] =94
   gradNumber[1] =88
   gradNumber[2] =45
   gradNumber[3] =95


 //printing the grades entered to be display on screen again.
    cout << "You have entered the following grades: " <<94“A”+88“B”+45“F”+95“A”<< endl; 
    for(count = 0; count <= 4; count++) //Starting with number 1. Number will increase each time after number is entered.
        total = total + grade[count];
    average = total/4;
    cout << "Your average of four grades are: " << 89.25 << endl; //Output of average
 //End of program

First and foremost, you don't have a legitimate C++ program, so there is no way you could have run the code you've enclosed.

#include <iostream>
using namespace std;

int main (void) {
  int Grades [4], Average, Total;

  for (int count=0; count < 4; count++) {
    cout << "Grade " << count + 1 << ": ";
    cin >> Grades [count];
    Total += Grades [count];
    }

  Average = Total / count;

  // Code something here to convert grades values to grade letters

  // Code something here to display grades and finally average

  return 0;
  }

This gives a real good idea how your other loops should be constructed, although I'd use a switch statement in one case.

@ShiftLeft,

I think the OP stated ...

average; // ... display in decimal

thus there is a problem with what you suggested, and also ...

int Grades [4], Average, Total; // you meant to have Total = 0; // here //
for (int count=0; count < 4; count++) {
    cout << "Grade " << count + 1 << ": ";
    cin >> Grades [count];
    Total += Grades [count]; // Total NEEDS an inital value of 0 //
}
Average = Total / count; // integer division here & ?scope of count? //

The above will only give the (rounded down) integer quotient (after integer division ... which integer value may also NOT help obtain the correct letter grade.)

To get the decimal fraction results, the OP desires,
it is easy to just do this:

#include <iostream>

const int NUM_GRADES = 4; 


int main( void ) 
{
    using std::cout; using std::cin;

    int grades[NUM_GRADES]; 
    double total = 0.0; // INITIAL to ZERO here //
    int count = 0 ; // count needs this 'scope' //
    while( count < NUM_GRADES ) 
    { 
        cout << "Grade " << (count + 1) << ": ";
        if( cin >> grades[count] && cin.get() == '\n' )
        {
            total += grades[count];
            ++ count; // update count ONLY on good data //
        }
        else // bad data entry ... so ...
        {
            cin.clear(); // clear any error flags //
            while( cin.get() != '\n' ) ; // flush cin stream //
            cout << "\nPlease enter integers only here ...\n";
        }
    }

    double average = total / count;

    // Code something here to convert grades values to grade letters
    // Code something here to display grades and finally average
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.