Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

Students also viewed these Databases questions

Question

=+ What are the subjects?

Answered: 1 week ago

Question

8. Why are pay-for-performance systems growing in importance?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago