0

需要帮助来重写这个循环,我觉得我很遥远,并且确定它不是正确的方法,它是唯一阻止我的程序运行的方法。任何人都可以引导我朝着正确的方向前进。如果您需要更多信息,请告诉我

//--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
4

1 回答 1

1

假设有一个成员变量my_qualityPoints,我也假设my_credits是。

不知道你为什么要在那里循环;你在my_credits增量的正确轨道上。

void student::completedCourse(double credits, double numericGrade)
{
    my_credits += credits;
    my_qualityPoints += credits * numericGrade;
}
于 2013-06-07T02:54:22.227 回答