I am working on a school project and I am supposed to write a function that
takes an array as an argument, ask for inputs, and then it is suppose to print the array elements in order. So far so good. The tricky part is that if the user inputs a non numeric value, the function should terminate the inputting process and just print the numeric values that were submitted prior to the non-numeric value.
I was thinking that I could use the sentinel value:
if item inputted is not a number, then terminate function and print array content.
My problem is converting this line to code. Is there a way to make a general statement using a sentinel value?
I am trying to write a loop using something like this:
In the "try" statements you will want to throw an error if the input stream fails. Here is a very basic example of try, throw and catch statements (from one of my past homework assignments):