Hello,
Im new to this forum and I really need help with this newbie problem. I've been struggling with this assignment for very long now. I'm not even sure how to start the code right, as well as the structure of it. My code is a complete mess, and Im not sure what I'm brainstorming here. Any help is appreciated. Here's whats being asked of me:
In a loop your program should do the following (you can use a do/while):
receive as data input the weights (proportions) for the four exam grades, and put these into an array called weights.
Read in 4 test grades into another array called grades.
Use the following test data for one example:
weights for exams: .10, .20, .25, .45
first student record: 75, 87, 79, 92
make up the rest yourself.
call the function isitvalid() passing in the grades array, the function returns a bool (i.e. a boolean value).
The function isitvalid() will determine whether or not the values in this array are valid. It will return true/1 for valid and false/0 if it's invalid. The function will return invalid if any grade in the array is not a valid grade (i.e. it's greater than 100 or less than 0). If the function returns false, your main program should read 4 values into the grades array again.
You should calculate and print the final grade, which is the weighted average.
Next your program will allow the user to see the any number of their test scores. For example. Your program can display a message such as: "If you don't believe the score is correct, how many of your grades would you like to see?", and it should call a function printarray() which takes two parameters, the array, and the number of grades the user would like to see..
The function printarray() does not return anything, it will print out the number of grades the user would like to see. For example if the user passed the number 2, it will print the first two grades from the grades array.
Your program will ask the user if s/he would like to enter another student.
At the end of your program, you should print the class average i.e. the average of all the final grades combined.
Here's what i got so far:
Yes, evidently Im very confused. Please help!Code:#include <iostream> #include <fstream> #include <math.h> using namespace std; bool isitvalid(double grades[]); void printarray(); int main(){ double weights[4], grades[4]; do { for (int i = 0; i < 4; i++){ cout << "weight " << i << " :"; cin >> weights[i]; } for (int k = 0; k < 4; k++){ cout << "grade: " << k ; cin >> grades[k]; } } while (cin); } bool isitvalid(double grades[]){ int k; bool cond = 0; if (grades[k] >= 0 && grades[k] <= 100){ cond = 1; }else{ cond = 0; return cond; } } } void printarray() cin >> k