Problem Solving With C++ (Looseleaf) - With Access
Problem Solving With C++ (Looseleaf) - With Access
9th Edition
ISBN: 9780133835267
Author: SAVITCH
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 8PP

Write a program that outputs a histogram of student grades for an assignment. The program should input each student’s grade as an integer and store the grade in a vector (covered in Chapter 8). Grades should be entered until the user enters −1 for a grade. The program should then scan through the vector and compute the histogram. In computing the histogram, the minimum value of a grade is 0 but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console. For example, if the input is:

20

30

4

20

30

30

−1

Then the output should be:

Number of 4's: 1

Number of 20's: 2

Number of 30's: 3

Blurred answer
Students have asked these similar questions
Write a program in C++ which asks the user to keep entering positive integers or -1 to quit. Then print how many values they entered, the value of each element they entered, and the average of the values (rounded to two decimal places). Requirements The code must use a vector to store the user data. Do not use a counter variable while asking the user for input. Instead, use the vector method to "push" values onto the vector, then later use the vector size method to determine how many values were pushed. The loop to show the values and calculate the average must use a "for each" loop iterator.
Define an integer vector and ask the user to give you values for the vector. because you used a vector, so you don't need to know the size. user should be able to enter a number until he wants(you can use while loop for termination. for example if the user enters any negative number, but until he enters a positive number, your program should read and push it inside of the vector). then
In PYTHON   Write a function that prints all elements of a vector from the first element up to the first occurrence of the element having value equal to a provide number   Use while loop(s)   Function Name:print_up_to_value Parameters:a_vector,a_value  Return:none   Example: Input: my_vector = [5,6,7,8,9,5,6,7,8,9] Invokefunction:print_up_to_value(my_vector,7)  Output:[5,6,7]

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Describe a method that can be used to gather a piece of data such as the users age.

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

Here is the code for the displayValue method, shown earlier in this chapter: public static void displayValue(in...

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

Personal Web Page Generator Write a program that asks the user for his or her name, and then asks the user to e...

Starting Out with Java: From Control Structures through Data Structures (3rd Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License