Question
Using C++ Write a program that asks the user for two numbers and displays their sum. The program should reject any non-number input. The program
Using C++ Write a program that asks the user for two numbers and displays their sum. The program should reject any non-number input. The program does this by reading the numbers in as C-Strings and then uses the following function to test the input: isNumber() - this function accepts a C-string as it's only argument. The function uses appropriate functions from chapter 10 to determine if the C-string passed to it contains a number. If it does, then it should return true, false otherwise. For example, if the C-string passed to it is "123.45" then the function returns true. If the C-string contains "12g" or "hello", then the function returns false. After the numbers are verified, they will need to be converted to an appropriate data type and then added together. Do not use global variables.
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