# student grades program need help coding it further

Page 1 of 1

## 3 Replies - 10615 Views - Last Post: 21 October 2006 - 10:58 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=19918&amp;s=db11c9b26585d68e61d1fe51046f7e85&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sunny123

Reputation: 0
• Posts: 11
• Joined: 19-October 06

# student grades program need help coding it further

Posted 20 October 2006 - 09:50 AM

this is a student grades program i have created which calculates the average of three grades entered and displays pass or fail depending on if average score is greater than or equal to 50.

i need help developing it further by using IF statements to decide whether the mark is pass or fail.(student passes if gets 40 or more in all three exams; aditionaly student passes if only one subject is failed but average is greater than or equal to 50). in all other instances the student fails.

if someone could start me of on the IF statement then i will get used to it as i have never done if statments and dont know how to start them of.

Program code shown below.
```#include <iostream.h>

//function declarations
void inputNumbers(int&,int&,int&);
int calculateAverage(int,int,int);
void displayAverage(int);

void main()
{//start of function main
int number1, number2, number3, average;
inputNumbers(number1,number2,number3);
average= calculateAverage(number1,number2,number3);
displayAverage (average);
}//end of function main

//definition of function inputNumbers
void inputNumbers(int&number1,int&number2,int&number3)
{//start of function inputNumbers
cout<<"Enter number 1:";
cin>>number1;
//prompt for number 2
cout<<"Enter number 2:";
cin>>number2;
//prompt for number 3
cout<<"Enter number 3:";
cin>>number3;
}//end of function input numbers

//definition of function calculateAverage
int calculateAverage(int number1, int number2, int number3)
{//start of function calculateAverage
int average;
average= number1+number2+number3/3;
return average;
}//end of function calculateAverage

//definition of function displayAverage
void displayAverage(int average)
{//start of function displayAverage
cout<<"The Average of the three grades is "<<average;
}//end of function displayAverage
```

edit: added [code] tags ~ jayman9

Is This A Good Question/Topic? 0

## Replies To: student grades program need help coding it further

### #2 UMTopSpinC7

Reputation: 0
• Posts: 47
• Joined: 20-October 06

## Re: student grades program need help coding it further

Posted 20 October 2006 - 01:41 PM

maybe this will help.

```int a;
int b;

if(a > b) {
cout << "this stuff is done if a is more than b\n";
}
else if(a == b) {
cout << "this stuff is done if a is equal to b\n";
}
else {
cout << "this stuff is done if neither of the two previous things were true\n";
cout << "in this case that means if a is less than b\n";
}

```

http://www.intap.net...pp/cpp04_02.htm

sunny123, on 20 Oct, 2006 - 09:50 AM, said:

this is a student grades program i have created which calculates the average of three grades entered and displays pass or fail depending on if average score is greater than or equal to 50.

i need help developing it further by using IF statements to decide whether the mark is pass or fail.(student passes if gets 40 or more in all three exams; aditionaly student passes if only one subject is failed but average is greater than or equal to 50). in all other instances the student fails.

if someone could start me of on the IF statement then i will get used to it as i have never done if statments and dont know how to start them of.

Program code shown below.
```#include <iostream.h>

//function declarations
void inputNumbers(int&,int&,int&);
int calculateAverage(int,int,int);
void displayAverage(int);

void main()
{//start of function main
int number1, number2, number3, average;
inputNumbers(number1,number2,number3);
average= calculateAverage(number1,number2,number3);
displayAverage (average);
}//end of function main

//definition of function inputNumbers
void inputNumbers(int&number1,int&number2,int&number3)
{//start of function inputNumbers
cout<<"Enter number 1:";
cin>>number1;
//prompt for number 2
cout<<"Enter number 2:";
cin>>number2;
//prompt for number 3
cout<<"Enter number 3:";
cin>>number3;
}//end of function input numbers

//definition of function calculateAverage
int calculateAverage(int number1, int number2, int number3)
{//start of function calculateAverage
int average;
average= number1+number2+number3/3;
return average;
}//end of function calculateAverage

//definition of function displayAverage
void displayAverage(int average)
{//start of function displayAverage
cout<<"The Average of the three grades is "<<average;
}//end of function displayAverage
```

edit: added [code] tags ~ jayman9

### #3 rockstar_

Reputation: 34
• Posts: 189
• Joined: 16-October 06

## Re: student grades program need help coding it further

Posted 20 October 2006 - 02:02 PM

sunny123, on 20 Oct, 2006 - 09:50 AM, said:

if someone could start me of on the IF statement then i will get used to it as i have never done if statments and dont know how to start them of.

You know, I really hate to say something like this, but you're really going to be better served by constructing your own IF-ELSEIF statement. This is a fundamental skill of any programmer. If you really want to learn the concept, write the code, watch it break, fix it, watch it break,...*snip*...fix it, watch it break, fix it, watch it work.

DIC has a great reference sheet for C++ that outlines syntax and everything. As you're learning C++, you should keep that close to your monitor so you can quickly look up syntax, etc. If you still need some help with logic, come back here after you've constructed something.

Be excited! You're about to learn some of the best parts of programming. Be patient with yourself, because programming is hard, even when you've been doing it for a while. You'll have nights where you tear your head straight from your head at 4 in the morning because you don't know why something isn't working. Then you'll go to bed, wake up, and realize you forgot a colon in your static method call...

rockstar_

### #4 gregoryH

Reputation: 60
• Posts: 656
• Joined: 04-October 06

## Re: student grades program need help coding it further

Posted 21 October 2006 - 10:58 PM

rockstar_, on 20 Oct, 2006 - 02:02 PM, said:

<snip> You'll have nights where you tear your head straight from your head at 4 in the morning because you don't know why something isn't working. Then you'll go to bed, wake up, and realize you forgot a colon in your static method call...

rockstar_

so true,,,

should see the size of the bald patch if it takes more than a week