好的,所以我正在做这个家庭作业,我老师的第一语言不是英语,而且并不总是最擅长指路。我正在尝试编写一个程序,要求提供期中成绩和期末考试成绩,然后将这两个值相加以显示总分。
我的问题是它似乎没有返回输入的分数或将它们存储在各自的变量中以便加在一起(也就是总显示为零)
这是我的代码:
// Lab11P2.cpp
#include<iostream>
using namespace std;
double getNcheckScore(double, double);
int main()
{
double midterm = 0.0;
double final = 0.0;
double total =0.0;
cout << "MIDTERM EXAM" << endl;
midterm == getNcheckScore(midterm, final);
cout << "FINAL EXAM" << endl;
final == getNcheckScore(midterm, final);
total = midterm + final;
cout << "Total score: " << total << endl;
system("pause");
return 0;
}
double getNcheckScore(double midterm, double final)
{
double score = 0.0;
cout << "Please enter your score: ";
cin >> score;
while (score < 0 || score > 100)
{
cout << "Score must be between 0 and 100. Please enter again: ";
cin >> score;
}
return score;
}