This is the code...
#include <iostream>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;
void CorrectPercent(double Percent) {
unsigned short int Error = 0;
while (Error==0){
cout << "\nEnter the annual interest rate (%):\t\t";
cin >> Percent;
do {
if (Percent <= 0) {
cout << endl << "Please enter a valid annual interest rate (%): ";
cin >> Percent;
} else if (isnan(Percent) == true) {
cout << endl << "Please enter a valid annual interest rate (%): ";
cin >> Percent;
}
else {
Error=1;
}
} while (Error == 0);
//Error++;
}//while (Error == 0);
}
int main()
{
double Percent;
char Retry = 'Y';
do
{
cout << setprecision(2) << fixed;
system("cls");
CorrectPercent(Percent);
} while (Retry == 'Y' || Retry == 'y');
return 0;
}
The CorrectPercent function is supposed to keep running until a valid numeric value is entered. So, the question is, how can I detect that the input is numeric? Just for additional info, I'm working on Visual Studio 2015.