Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ help no maps just use an array in the class Lab 1: Arrays and Classes 1. Consider a situation, such as a lottery, where
C++ help no maps just use an array in the class
Lab 1: Arrays and Classes 1. Consider a situation, such as a lottery, where over time certain numbers appear. Wayne wants to know how often each number appears. In C++, create a class Number Count to count the occurrences of numbers. The class should use an array for storage. The methods that the class should have are: Unique constructor takes two arguments: the minimum and maximum num- ber that can occur. void addElement(int number): increment the count of number bool removeElement(int number): decrement the count of number void display(): draw the results as a histogram 2. Also create a main function in TestNumberCount.cpp that properly exercises your class. For example: NumberCount N(11,16); N.addElement(12); N.addElement(12); N.addElement(12); N.addElement(14); N.addElement(17); N.addElement(13); N.removeElement(11); N.removeElement(13); N.display(); produces: 17 Out of range; 11 not present; 11: 12:*** 13: 14:* 15: 16: Submit via handin. Note that in C++, an array can be dynamically allocated using the new command. For example: int *A = new int[MAX-MIN+1]; Your code should work on our system compiled with g++ -Wall -std=c++11 NumberCount.cpp TestNumberCount.cppStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started