Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ function named isvalidReal() that checks for a valid double-precision number. This kind of number can have an optional + or - sign,

Write a C++ function named isvalidReal() that checks for a valid double-precision number. This kind of number can have an optional + or - sign, at most one decimal point (which can be the first character), and at least one digit between 0 and 9. The function should return a Boolean value of true if the entered number is a real number; otherwise, it should return a Boolean value of false. Then modify the isvalidReal() function written to remove all leading and trailing blank spaces from its string argument before determining whether the string corresponds to a valid real number.

** This is what I have so far for this program. I feel like I am close, just need some help tweaking and debugging as it is not recognizing the real number. The feedback I got was "You have to check for a decimal point. Just One." I have to be overlooking something simple: **

image text in transcribed

11 | E#include 12 13 14 15 bool isvalidReal(string); 16 17 int main() 18 19 20 21 #include using namespace std; string str; double number; cout = 1) valid = false; i = start ; while (valid && double(str.length())) if (lisdigit(str.at(1))) valid false; if (str.at (i) == '-') valid = true; 56 57 58 59 60 61 62 return valid

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

Define promotion.

Answered: 1 week ago

Question

Write a note on transfer policy.

Answered: 1 week ago

Question

Discuss about training and development in India?

Answered: 1 week ago

Question

Explain the various techniques of training and development.

Answered: 1 week ago

Question

1. Identify what positions are included in the plan.

Answered: 1 week ago

Question

2. Identify the employees who are included in the plan.

Answered: 1 week ago