Hello again :)
I had this project (first block of codes below) and out of this program i have to do the same again but this time using functions.
My problem now is, i made some functions ( i hope these are functions) but on the last part (the one with the if else statements) i receive error messages.
Maybe one of you knows what i did wrong there. (Second block of codes below)
#include <iostream>
#include <string>
using namespace std;
main()
{
string name, course[10];
int x, y, n;
float grade[10];
char response;
cout<< "Please enter your name: ";
cin>> name;
cout<< "Please enter number of subjects: ";
cin>> y;
cout<< "Hello " << name << " you have " << y << " subjects." << endl << endl;
n=1;
for(int a=0; a<y; a++)
{
cout<< "Please enter your course " << n << ":";
cin>> course[a];
cout<< endl;
cout<< "Please enter your Grade: ";
cin>> grade[a];
cout<< endl;
n++;
}
cout<< "Course\tGrade\tEquivalent\tRemarks " << endl;
for(int ctr=0;ctr<y;ctr++)
{
if (grade[ctr] > 5.0)
cout<< course[ctr] << "\t" << grade[ctr] << "\t75%\ - lower \t Failed" << endl;
else if (grade[ctr] == 3.0)
cout<< course[ctr] << "\t" << grade[ctr] << "\t75% \t\t passed"<< endl;
else if (grade[ctr] <=2.75)
cout<< course[ctr] << "\t" << grade[ctr] << "\t78% \t\t passed"<< endl;
else if (grade[ctr] =2.5)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t81% \t\t passed"<< endl;
else if (grade[ctr] <=2.25)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t84% \t\t passed"<< endl;
else if (grade[ctr] <=2.0)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t87% \t\t passed"<< endl;
else if (grade[ctr] <=1.75)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t90% \t\t passed"<< endl;
else if (grade[ctr] <=1.5)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t\t 93%\t passed"<< endl;
else if (grade[ctr] <=1.25)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t96% \t\t passed"<< endl;
else if (grade[ctr] ==1.0)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t100% \t\t passed"<< endl;
else
cout<<"invalid input of grade"<< endl;
}
cin>> response;
return 0;
}
BLOCK 2
#include <iostream>
#include <string>
using namespace std;
void EnterName ()
{
cout<< "Enter your name: ";
}
void EnterSubject ()
{
cout<< "Enter the number of subjects: ";
}
void Greetings (double x, double y)
{
cout<< "Hello " << x << " you have " << y << " subjects.";
}
void EnterCourse (int n)
{
cout<< "Please enter your course " << n << ":";
}
void EnterGrade ()
{
cout<< "Please enter your Grade: ";
}
void Titel ()
{
cout<< "Course\tGrade\tEquivalent\tRemarks " << endl;
}
void Evaluation (float grade, string course[10], int ctr)
{
if (grade[ctr] > 5.0)
cout<< course[ctr] << "\t" << grade[ctr] << "\t75%\ - lower \t Failed" << endl;
else if (grade[ctr] == 3.0)
cout<< course[ctr] << "\t" << grade[ctr] << "\t75% \t\t passed"<< endl;
else if (grade[ctr] <=2.75)
cout<< course[ctr] << "\t" << grade[ctr] << "\t78% \t\t passed"<< endl;
else if (grade[ctr] =2.5)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t81% \t\t passed"<< endl;
else if (grade[ctr] <=2.25)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t84% \t\t passed"<< endl;
else if (grade[ctr] <=2.0)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t87% \t\t passed"<< endl;
else if (grade[ctr] <=1.75)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t90% \t\t passed"<< endl;
else if (grade[ctr] <=1.5)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t\t 93%\t passed"<< endl;
else if (grade[ctr] <=1.25)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t96% \t\t passed"<< endl;
else if (grade[ctr] ==1.0)
cout<< course[ctr]<< "\t" << grade[ctr] << "\t100% \t\t passed"<< endl;
else
cout<<"invalid input of grade"<< endl;
}
main()
{
string name, course[10];
int a, b, c, x, y, n;
float grade[10];
char response;
void EnterName ()
cin>> name;
void EnterSubject ()
cin>> y;
void Greetings (double b, double c)
n=1;
for(int a=0; a<y; a++)
{
void EnterCourse ()
cin>> course[a];
void EnterGrade ()
cin>> grade[a];
cout<< endl;
n++;
}
void Titel ()
for(int ctr=0;ctr<y;ctr++)
{
void Evaluation (double x, double y)
}
cin>> response;
return 0;
}
Thank you for taking your time for it.