repetition and invalid if statement

closed account (1RLTURfi)
somebody help...i want this program continuous.and my if else got problem.someone help me..

#include <iostream>
#include <cmath>
using namespace std;


double get_score(double,double,double,double,double);
double get_Final_Score(double,double,double,double,double);
void grade(double );

int main()


{
int a ;
double score, b , c , d , e , f ;


cout << "Please enter your student number." << endl;
cin >> a;

cout << "\nPlease enter your marks for exam." << endl;
cin >> b;

cout << "\nPlease enter your marks for quiz." << endl;
cin >> c;

cout << "\nPlease enter your marks for programming assignment." << endl;
cin >> d;

cout << "\nPlease enter your marks for lab exercise." << endl;
cin >> e;

cout << "\nPlease enter your marks for test." << endl;
cin >> f;


get_score(b , c , d , e , f);




cout << "\nStudent Number:" << " " << a << endl;
cout << "=======================";
cout << "\nMarks for exam is:" << " " << b << endl;
cout << "Marks for quiz is:" << " " << c << endl;
cout << "Marks for programming assignment is:" << " " << d << endl;
cout << "Marks for lab exercise is:" << " " << e << endl;
cout << "Marks for test is:" << " " << f << endl;


score = get_Final_Score(b, c ,d , e ,f ); //function called here




cout << "Final Score is" << " " << score << endl;

grade(score);


system ("pause");

return 0;

}

double get_score(double b , double c ,double d , double e , double f)
{



if ( b > 100 )
cout << "Invalid mark was entered." << endl;
if ( c > 100 )
cout << "Invalid mark was entered." << endl;
if ( d > 100 )
cout << "Invalid mark was entered." << endl;
if ( e > 100 )
cout << "Invalid mark was entered." << endl;
if ( f > 100 )
cout << "Invalid mark was entered." << endl;

return b , c , d , e , f ;


}

double get_Final_Score(double b ,double c ,double d ,double e , double f)
{
double score;

double avg_b = (b / 100) * 30; // finds average of b
double avg_c = (c / 100) * 10; // finds average of c
double avg_d = (d / 100) * 15; // finds average of d
double avg_e = (e / 100) * 25; // finds average of e
double avg_f = (f / 100) * 20; // finds average of f
double avg_a = (avg_b + avg_c + avg_d + avg_e + avg_f);
return avg_a;


return avg_a ;
}

void grade(double score)
{




if ( score >= 0 && score <= 49.9)
cout << "Grade is" << " " << "F" << endl;
else if ( score >= 50 && score <= 59.9 )
cout << "Grade is" << " " << "D" << endl;
else if ( score >= 60 && score <= 69.9 )
cout << "Grade is" << " " << "C" << endl;
else if ( score >= 70 && score <= 79.9 )
cout << "Grade is" << " " << "B" << endl;
else if ( score >= 80 && score <= 100 )
cout << "Grade is" << " " << "A" << endl;


return;

}
You can put a do...while loop in your main() function...

eg.
1
2
3
4
5
6
7
8
9
10
bool repeatProcess = false;

do
{
    // your logic

    // Ask if whether they want to repeat the process and set repeatProcess variable based on 
    // their input
}
while(repeatProcess);


which if else are you referring to?
Last edited on
closed account (1RLTURfi)
eh.."the invalid mark was entered".i wan use this as function.but its was weird.you try run it.after i type in 5 integer those are >100,the "invalid mark was entered" only appear , 5 times appear.u get what i said .keke
What is it that you want your get_score function to do?

Why does it have a return value?
Topic archived. No new replies allowed.