Question: Write a program that prompts the user to enter two positive whole numbers as strings! Create a function that validates the input and returns true

Write a program that prompts the user to enter two positive whole numbers as strings! Create a function that validates the input and returns true if all chars in the string are digits. Call the function from the main and prompt the user to re -enter if any invalid input was entered. Create a second function that converts the string to an int and returns it. The program then converts both strings to integers and computes and prints out the sum.

Hints: For example:

4127 can be split up as 4* 1000 + 1* 100 + 2 * 10 + 7 * 1 .

You can convert a char ch to an int by subtracting 0 from it: int num = ( int)ch - '0' ;

CANNOT USE ANY OTHER FUNCTION LIBRARY THAN IOSTREAM AND STRING.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!