| 46 | const unsigned NOT_AVAILABLE = std::numeric_limits<unsigned>::max(); |
| 47 | |
| 48 | int main() |
| 49 | { |
| 50 | std::vector<unsigned> grades; |
| 51 | |
| 52 | std::cout << "Please enter a number of grades (0-100), terminated by a negative one:" << std::endl; |
| 53 | while (true) |
| 54 | { |
| 55 | int number{}; |
| 56 | std::cin >> number; |
| 57 | if (number < 0) |
| 58 | break; |
| 59 | else if (number > 100) |
| 60 | std::cout << "Only numbers < 100, please..." << std::endl; |
| 61 | else |
| 62 | grades.push_back(number); |
| 63 | } |
| 64 | |
| 65 | sort(grades); |
| 66 | |
| 67 | // Note: thruth be told, this is based on an old solution. |
| 68 | // It would be better and/or easier |
| 69 | // a) to use std::array<> instead of C-style arrays; and |
| 70 | // b) to return the values requested rather than using output parameters |
| 71 | // Perhaps you can improve our solution accordingly? |
| 72 | unsigned highest[5]{}; |
| 73 | unsigned lowest[5]{}; |
| 74 | |
| 75 | getHighest(grades, highest); |
| 76 | getLowest(grades, lowest); |
| 77 | |
| 78 | printNumbers("Five highest grades", highest); |
| 79 | printNumbers("Five lowest grades", lowest); |
| 80 | printNumber("The grade average", computeAverage(grades)); |
| 81 | printNumber("The median grade", computeMedian(grades)); |
| 82 | printNumber("The standard deviation of the grades", computeStandardDeviation(grades)); |
| 83 | printNumber("The variance of the grades", computeVariance(grades)); |
| 84 | } |
| 85 | |
| 86 | // Swap numbers at position first with address at position second |
| 87 | void swap(std::vector<unsigned>& numbers, size_t first, size_t second) |
nothing calls this directly
no test coverage detected