Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

c++ - Outputting the correct letter grade based on the grades being inputted in


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

grade1+grade2+grade3/3 is wrong. Division is calculated before addition in C++, so only grade3 is divided by 3 while grade1 and grade2 are not divided.

You have already calculated average, so you should use that instead of the wrong formulas.

Also the condition looks wrong. It seems you should use >= or > (according to the specification) instead of <=.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...