### Need help with homework

keep getting errors :(
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778`` `````` #include "stdafx.h" // Needed for Visual C++ Express 2010 #include using namespace std; // Here’s where you will need your function prototype // Think of this as a way to declare your function. char grades(double) int main() { float sumofgrades, avaerage; char lettergrade; float grade1, grade2, grade3; grade1 = 94.0; grade2 = 91.3; grade3 = 89.33; sumofgrades = grade1 + grade2 + grade3; average = sumofgrades / 3.0; // Here you will need to call your function // It will be a function that returns a character // letter grade. You will pass the numerical average // as a parameter. lettergrade = grades (average); cout << “Your letter grade earned is: “ << lettergrade << endl; return 0; } char grades(double average) float sumofgrades, average; char lettergrade; float grade1, grade2, grade3; { if (average >= 90.0) { lettergrade = 'A'; } else if (( average >= 80.0) && (average < 90.0)) { lettergrade = 'B'; } else if ((average >= 70.0) && (average < 80.0)) { lettergrade = 'C'; } else if ((average >= 60.0) && (average < 70.0)) { lettergrade = 'D'; } else if (average < 60.0) { lettergrade = 'F'; } return lettergrade; } // Here you will need to code your function here. You must provide the header and the body and use // the logic below to determine the earned letter grade: /* * A-range: 100.0 90.0 * B-range: 80.0 - 89.9 * C-range: 70.0 - 79.9 * D-range: 60.0 = 69.9 * F < 60 */``````
You'll notice that the key issue here is that you are missing several semicolons, and misplaced a few braces. Also, for your if loop for the letter grade, you don't have to check whether the number is below 90, 80, et cetera. If it falls above the expected range, it would already be picked up by the if statement above.
Last edited on
If you want to help in this matter why not join this http://www.Findomia.com platform.
Also you never use sum of grades. To me it looks like you need to learn Syntax before anyone can help you. You should get error messages saying missing semi colon at line ... and missing brace before line ....

By the way "Keep getting errors" is not a question. You should read the error messages and if you some how can not figure out what a missing semicolon at line ... is then ask and maybe we can help

*edit sum of grades in your letter finding function I should say
Last edited on
Things that I noticed

**Average is spelled a couple of different ways in the main method, has to be spelled the same and is case-sensitive.

**Correct me if I am wrong but you cannot interchange data-types when passing to the function. For example average is float data type but the function grades is double.
float and double are automatically converted AFAIK just like if you put a double in a function that takes ints as a prototype or a short/long in place of int. *unless they are overloaded functions.
very well
Topic archived. No new replies allowed.