Hello iRatedRetro,
You have a good start to your program, but some of it is wrong. I would not scrap the program you have, but rearrange it better.
First I would start with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
//User Libraries
//Global Constants - Math/Physics Constants, Conversions,
// 2-D Array Dimensions
// 2D array dimensions.
constexpr size_t MAXROWS{ 5 };
constexpr size_t MAXCOLS{ 4 };
//Function Prototypes // <-- Leads one to believe there is more than one prototype.
//Execution Begins Here
int main() // <--- I do not see where you are using 'argc" or "argv". Unless you have a future use they are not needed.
{
//set random number seed
// <--- Do you need this and where is it? You do not have the proper header files either. <ctime> and <cstdlib>
//Declare Variables
//Initialize Variables
//Process/Map inputs to outputs. Do you mean process the 2D array?
//Output data
// <--- You may find this useful.
// The next line may not be needed. If you have to press enter to see the prompt it is not needed.
//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
std::cout << "\n\n Press Enter to continue";
std::cin.get();
//Exit stage right!
return 0;
}
// <--- Put functions here.
|
I would start with this and put your code where it is needed. The code for inputting the data is OK works. I would also consider putting this code in a function and just call it from main.
The for loops for the average I would put in a function then copy it for a second function to drop the lowest score and return that average.
Your function for "letterG()", but if I may suggest I would call it "LetterGrade()" or "GetLetterGrade" as it is more descriptive of what it does. Notice how the function name starts with a capital letter. For me this is a way to tell you that it is a function and not a variable which should start with a lower case letter.
Your if/else if statements are on the right track, but off a bit. Looking at the code a score of 90 could be either an "A" or "B". Not what you want. look at what is required:
1 2 3 4 5 6
|
Test Score Letter Grade
90–100 A
80–89 B
70–79 C
60–69 D
0–59 F
|
The >= 90 followed by <= 90 does not make any sense. The if/else if statements would work better as:
1 2 3 4
|
if (score > 89 && score <= 100) return "A";
else if (score >79 && score < 90) return "B";
else if (score > 69 && score < 80) return "C";
// <--- The rest here.
|
Also look at JLBorges's approach. It is shorter and will work the same as above. It is worth considering
In a previous message you said
and i cant use doubles only floats
. But your instructions clearly start
five arrays of four doubles to hold each student’s set of test scores.
That says to me that the 2D array should be of type "double".
Your other variables are OK and I did not find anything wrong with them. I did add one variable of type "double" I called "minScore" that I used when dropping the lowest score before the average. I put this in main, but if you put the code for this average in a function only the function will need this variable.
I have my ideas on this program that I will work on. If there is anything that you have a question on let me know.
Hope that helps,
Andy