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.
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:

Code:
```#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
void printarray();
int main(){
do
{
for (int i = 0; i < 4; i++){
cout << "weight " << i << " :";
cin >> weights[i];
}
for (int k = 0; k < 4; k++){
cout << "grade: " << k ;
}
}
while (cin);
}

int k;
bool cond = 0;
cond = 1;
}else{
cond = 0;
return cond;
}
}
}
void printarray()
cin >> k```

2. The math header should be
Code:
`#include <cmath>`
Also, inside isitvalid(), you need to loop through k=0 to k=3. If any one of the grades is invalid, you can immediately return false (from inside the loop). If you finish the loop, then return true.

3. Ok thank you, but which parameters should I use in order for main to call the function properly and where do I need to put the function in the main for it to be actually checking the grades. It also has to go back to intitializing grades[] if false, how will my logic look for it to work this way?
Here's what I got so far, but Im not sure what its doing. Plus in this configuration it says " [Warning] the address of `bool isitvalid(double*)', will always evaluate as `true' ".

Code:
```#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
void printarray();
int main(){

do
{
for (int i = 0; i < 4; i++){
cout << "weight: ";
cin >> weights[i];
}
for (int k = 0; k < 4; k++){
}
}
while(isitvalid);
}

int k;
for (k = 0; k < 4; k++){
return true;
}else{
return false;
}
}
}```
Can you please show me a primitive example of this piece of code just to guide me in the right direction. Thank you!

4. You can't call isitvalid() until after all the grades have been entered - right now you're calling it after each grade is entered. Also, inside isitvalid(), you have false and true backwards - you need to check each grade to see if it's INvalid, and if so return false - otherwise return true. Finally, you should indent consistently - say a fixed number of spaces or tabs per indentation level.

Edit: I misunderstood how you're calling isitvalid() - it looks like you're checking your data after entering all of it, but it should be
Code:
`while (!isitvalid(grades));`
since you only have to reenter the data if it's NOT valid.

5. Actually I made a mistake, it should check inside while loop and should look something like this:
Code:
```for (int i = 0; i < 4; i++){
cout << "weight: ";
cin >> weights[i];
}
for (int k = 0; k < 4; k++){
}
}
while (cin);
}```
But, my function is just not doing anything because its wrong. I dont understand when you say i have it backwards. I'm a newb to this so for me even putting right parameters is hard. Also I dont understand even if it works and returns "false" then how can I make it go back and cycle through grades again? I'd really appreciate it if you could take piece of my code and put it in right C++ context such as right parameters and proper logic in function so I could keep working on it. Thanks for all your help.

Also I have another improperly structured function to attach that needs to ask which grades to print to screen from array here it is so far:
Code:
```void printarray(double grades[k], int n){
char more;
int nums;
while (more == 'y'){
cin >> more;
cout << "how many? ";
cin  >> nums;
for (n = 0; n < nums - 1; n++){
}
return;
}
}
}```
then my code needs to find average of all grades in array.

I spent 2 days including thanksgiving working on this code, please try to give me little bit more detail on how to put these 2 functions together with main. Looks like such a simple task and I cant even get it close to working.

6. First, you really need to indent - your code is very hard to read. In isitvalid(), you return false if any one of the grades is false, otherwise return true. So the logic should look like:
Code:
```for (k loop) {
if (grades[k] is invalid) return false;
}
return true;```
So if any one of the grades is invalid, it returns false immediately. On the other hand, if they are all valid, you finish and exit the loop, and return true.

7. You mean like this?
Code:
```bool isitvalid(double grades[]){
for (int g = 0; g < 4; g++){
return false;
}else{
return true;
}
}
}```
It works but always returns as true. I think the problem is that Im not referencing my parameters correctly and its not actually checking my grades.
Where does it go wrong?
Here's the whole code:
Code:
```#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
bool isitvalid(double []);
void printarray(double, int);
int main(){
int g = 4;
double average,count = 0, weights[4], grades[g];
int n;
do
{
for (int i = 0; i < 4; i++){
cout << "weight: ";
cin >> weights[i];
}
for (int k = 0; k < g; k++){
}
average = count / g;
cout << count << endl;
cout << average << endl;
}
}
for (int g = 0; g < 4; g++){
return false;
}else{
return true;
}
}
}```

8. It should be "||", not "&&". Also, the "else" shouldn't be there, and the "return true;" should be _outside_ the loop. Remember that you can never return true until all grades have been validated, but you can return false if a single grade isn't valid. So "return false;" should be inside the loop, and "return true;" should be outside the loop. Take another look at my pseudocode above.

9. I've done it the way you told me, but it still always returns it as "true".
I think its because of my function parameter (double grades[]), its not checking the numbers in grades[] array in the main function.

10. The line should be
Code:
`while (!isitvalid(grades));`
(note the exclamation point) since you stop the do loop when isitvalid(grades) is true. Also, the code in isitvalid should look like
Code:
```  for (int g = 0; g < 4; g++) {