|
-
Feb 22nd, 2002, 03:44 PM
#1
Thread Starter
Junior Member
Numeric or not??
I am asking the user to enter a number and want to display an error message and ask again if the user incorrectly enters an alpha character.
These work with the correct input (numeric), but won't work with the wrong input (alpha)
Please help
void get_loan_amount(double& lamount)
{
using namespace std;
do
{
cout << "Please enter the loan amount: $";
cin >> lamount;
} while (isalpha(lamount));
return;
}
OR
void get_loan_amount(double& lamount)
{
using namespace std;
double amount;
do
{
cout << "Please enter the loan amount: $";
cin >> amount;
lamount = amount;
} while (!isdigit(amount));
return;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|