Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that outputs a histogram of grades for an assignment given to a class of students. The program should input each students grade

Write a program that outputs a histogram of grades for an assignment given to a class of students. The program should input each students grade as an integer and store the grade in a vector. Grades should be entered until the user enters -1 for a grade. Use a map from an int to an int to compute the histogram. The first integer in the map represents the grade and the second integer represents the number of times that grade occurred. Output the histogram to the console. Break the histogram bins into values of 10, that is, grades between 0-10 are in bin 1 (call it 10), grades between 11-20 are in bin 2 (call it 20), grades between 21-30 are in bin 3 (call it 30), etc until the highest bin for your grades. There should be no restrictions on the minimum and maximum grade for this programming project, that is, the bins are not stopping at 100, add as many as needed based on user input. A sample output (for input values up to 99 by the user) is shown below: The histogram for the grades entered is: 10: 0 20: 0 30: 2 40: 1 50: 4 60: 9 70: 16 80: 25 90: 8 100: 5 Use the following sequence of grades as a test input (enter them one per line or separated by a space for easier entry): 79, 5, 112, 60, 75, 98, 105, 34, 90, 90, 49, 25, 12, 98, 119, 76, 80, 81, 67, 99, 56, 98, -1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions