Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ help Lab 1: Arrays and Classes 1. Consider a situation, such as a lottery, where over time certain numbers appear. Wayne wants to know

C++ helpimage text in transcribed

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 NumberCount 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.cpp

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

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions