C ++初学者在这里。 因此,我正在尝试使此代码功能像最终成绩计算器一样,但无法正常工作。每次返回100。怎么了?
#include <iostream>
using namespace std;
int main()
{
double grade, des, worth, per, grade1, tgrade, fgrade;
cout<<"What is your current grade in the class?"<<endl;
cin>>grade;
cout<<"What is your desired grade in the class?"<<endl;
cin>>des;
cout<<"How much is your final exam worth? (Percent of total grade)"<<endl;
cin>>worth;
per=1-(worth/100);
grade1=grade*per;
fgrade=100;
while ((tgrade-0.01)<=des<=(tgrade+0.01)) {
fgrade=fgrade-1;
tgrade=grade1+(fgrade*(worth/100));
}
cout<<"You need a grade of "<<fgrade<<"% on your final exam to reach your desired grade in your class. Good Luck!"<<endl;
return 0;
}
答案 0 :(得分:0)
我可以看到您想要在循环条件下实现的逻辑,但是<=是 binary 运算符,因此您需要具有两个与&&结合的条件。
Table A:
Id & EmployerName
Table B:
Id, Employeename & EmployerID