Member Avatar for cscode001
cscode001

Hello. I am new this website and a beginner in Computer Science. I have very little experience in C++. Recently I have been working on this lab and I am stuck at a point where I don't know what to do. Can any1 help me with this code?

Here is my code so far.

#include <iostream>
#include <string>

using namespace std;

float weightedAverage(int, float, int);
void avgToLetter(float, char)
int main()
{
	int grades[] = {100, 80, 75, 95};
	int numGrades = 4;
	float weights[] = {1.0, 1.5, 2.0, 2.5};

	for(weightedAverage(grade[] * weights[])/(weights + weights))
}
void agvToLetter(float avg, char letterGrade)
{

}

The question to build the code from:
Search for validating data
Write a function allValid that takes an array of integer grades and the size of the array as parameters. The function returns the index of the first value that is negative or over 100. If this is not true of any of the values, they are all valid, and the function returns the size of the array.
Write a driver to test this function. A driver in this context is code that controls other code. A test driver is a main() that calls the other code to test if it produces the correct result.

Weighted grades
Write a function called weightedAverage that takes an array of integer grades, an array of weights stored as floats, and the size of the array called numGrades. Note that we are only using one size variable here (do you think this is ok? Why or why not?) The function returns a float that is the weighted average of the grades.
To explain this a bit, weightedAverage should multiply each grade by the corresponding weight and add up all of the weighted grades. It should then divide this by the sum of the weights. (Why do we do this instead of dividing by the number of grades?). For example, if the array of grades is { 100, 85 } and the array of weights is { 1.0, 2.0 }, the weighted average = 90.0. [Feel free to write additional functions to help you implement weightedAverage.]
Write another function avgToLetter that takes a parameter avg and returns the equivalent letter grade. To keep things a bit simpler, you do not need to manage minuses and pluses. (It would just involve more typing.) Also, you can simply store the grades and weights in local variables of main(). Anything less than 59.5 is an 'F', anything less than 69.5 is a 'D', and so on.
Write a driver that tests the code you have written. It should still first display a welcome message explaining what the program does. It will then initialize arrays with appropriate values to test the functions. With these arrays, you still want to pass them through the allValid function above. If there are any invalid grades, print an error message indicating which grade is not valid and exit the program. If all grades are valid, print out the final grade (be sure to print enough text so the user knows what the result means).

Please Can Anyone Help Me. I really, really need help.

Thanks in advance.