需要帮助来重写这个循环,我觉得我已经离开了,并确定它不是正确的方法,它是唯一阻止我的程序运行。任何人都可以带领我朝着正确的方向前进。如果您需要更多信息,请告诉我
//--modifier
void student::completedCourse(double credits, double numericGrade)
{
my_credits += credits;
for (my_qualityPoints; credits; numericGrade;)
}
这是来自头文件
//--modifier
void completedCourse(double credits, double numericGrade);
// post: record a completed course by adding credits to my_credits
// and incrementing the qualityPoints by (credits * numericGrade)
// aStudent.completedCourse(4.0, 3.67) // a 4 credit A- perhaps
答案 0 :(得分:1)
假设有一个成员变量my_qualityPoints
,我也认为my_credits
也是。
不确定你为什么要在那里做一个循环;你在my_credits
增量的正确轨道上。
void student::completedCourse(double credits, double numericGrade)
{
my_credits += credits;
my_qualityPoints += credits * numericGrade;
}