Why is my input ask the user to enter the score twice?
#include<iostream>
using namespace std;
void getScore(int&);
void printGrade(int);
int main()
{
int score;
int course;
getScore(score);
printGrade(course);
return 0;
}
void getScore(int& score){
cout<<"Please enter your score: ";
cin>>score;
cout<<"Your course score is: "<<score<<endl;
}
void printGrade(int course){
getScore(course); //im not really sure about this, correct me if im wrong
if(course<0 || course>100)
cout<<"Wrong input! Try again!"<<endl;
else if(course>90)
cout<<"Course grade= A"<<endl;
else if(course>70)
cout<<"Course grade= B"<<endl;
else if(course>=50)
cout<<"Course grade= C"<<endl;
else
cout<<"Course grade= D"<<endl;
}
oh crap! my fault. Im new to this forum, thats why. Btw, thanks. I get it now, simple mistake. how can i overlooked it.
You're welcome - glad it worked out :)