bwa11
1
What is wrong with this code? Test 11 and 12 pass. Test 10 failed.
// Create a list of grade thresholds based on the provided highest grade.
std::array<int, 4> letter_grades(int highest_score) {
double lowest = 41;
std::array<int, 4> grades;
double average = (highest_score - lowest) / 4.0;
grades[3] = highest_score - static_cast<int>(average);
grades[2] = grades[3] - static_cast<int>(average);
grades[1] = grades[2] - static_cast<int>(average);
grades[0] = lowest;
return grades;
}
Test 10 output:
FAILED:
REQUIRE( expected == actual )
with expansion:
{ 41, 56, 71, 86 } == { 41, 58, 72, 86 }
at /tmp/making-the-grade/making_the_grade_test.cpp:93
bwa11
3
@IsaacG
- Yes
- Yes
- Yes
- I am trying to.
I reverse engineered what I saw in the test to figure out how to configure the function. Something is slightly off so test 10 fails.
IsaacG
4
With those inputs, what is the value of each variable on each line?
1 Like
bwa11
5
@IsaacG Thanks!
I could have actually figured this out with just a few print statements.
As soon as I ask a question in the forum I figure out how to do what I need to do.
grades[2] = grades[3] - static_cast<int>(std::ceil(average));
grades[1] = grades[2] - static_cast<int>(std::ceil(average));
I have passed test 10.
Is there no one to mentor C++? I have not had anyone mentor me in C++ yet.
IsaacG
6
Nicely done!
Iām pretty sure there are some C++ mentors but the C++ queue does look pretty backed up at the moment
2 Likes