function prototype computer science homework help

Problem 1:

To access a subtring of a string str, you can use the function defined by the following function prototype:

string substr(size_t startIndex, size_t length);

However if startIndex > str.size(), this substr function will cause an out_of_range exception and terminate the program.

Write an StrExcept exception class that inherits from the base exception class out_of_range by defining its own constructor and a print() method outputtinga custom error message to the user.

Then, in the main method, write a program that asks the user to enter a string before asking him/her to enter the start index of the substring and its length.

This program should throw StrExcept if the start index is larger than the size of the string and handle this exception by surrounding it by try-catch block.

Note that out_of_range class would require you to include stdexcept library.

Problem2:

Write a recursive version of the binary search algorithm.

Function prototype: int bSearch(const int a[],int lo, int hi,int x)

Where lo and hi are the indexes of the first and last element of the binary search.

Note: You can assume that the items of the searched array to test in your main method are sorted/

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.