Question
For this lab, you will need to write a program where the user inputs numeric values from 1 through 10 and outputs a textual histogram
For this lab, you will need to write a program where the user inputs numeric values from 1 through 10 and outputs a textual histogram of the values using *s to count the number of occurrences of each value. However, users often enter bad or incorrect data, so you are going to need to use exception handling to catch the errors. If the user enters a value that does not consist of all digits or number outside the range of 1-5 (e.g. 19, A, asdf), then an exception should be thrown and caught.
In order to do this, you should get the value as a string and then scan through the string and then check to see if it contains all digits. You can use the isdigit(char) function from to help with this.
To convert a string to an integer, use the following code: atoi(stringname.c_str());
You will need to use at least two exception handlers for this program. One exception handler should deal with the case where the user enters invalid data such as characters while the other should deal with the case where the user enters a value that is too large or too small (e.g. negative numbers).
C++ please! Thanks!
Step 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