Write a C++ program that reads a file consisting of students’ test scores in the
ID: 3759863 • Letter: W
Question
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. An input data file, scoreData.txt, has been provided for testing. Analyze and design the program. Implement the design, compile and test it with the data file provided. Turn in your analysis and design and your source code.
Explanation / Answer
#include #include using namespace std; int main() { ifstream inFile; inFile.open("grades.txt"); if (!inFile) { cout > numStudents; int num; int rangeOne, rangeTwo, rangeThree, rangeFour, rangeFive, rangeSix, rangeSeven, rangeEight; // conditionals while (inFile.good()) { getline (inFile, num); if (num < 24) { rangeOne++; } else { if (num > 24 && num < 50) { rangeTwo++; } } else { if (num > 49 && num < 75) { rangeThree++; } } else { if (num > 74 && num < 100) { rangeFour++; } } else { if (num > 99 && num < 125) { rangeFive++; } } else { if (num > 124 && num < 150) { rangeSix++; } } else { if (num > 149 && num < 175) { rangeSeven++; } } else { if (num > 174 && num < 200) { rangeEight++; } } else { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.