>>2 Here's the current code I have. Sorry it took so long. I made this thread when I was at home and Programming is my last class of the day. The program is supposed to only accept integers(i.e. 1,4,7,9.0, etc.), and if 0 is entered it stops the loop and calculates everything mentioned in the program description, but does not count 0. Zero cannot be entered first, it cannot accept letters or symbols, and it can not accept floating point numbers(i.e. 9.2, 9.02, 9.00009, etc. along those lines). For each invalid entry, a message is displayed telling them that it is wrong and the loop continues asking them for another integer. The messages are easy enough to display, but its the actual code to catch those specific errors that I'm having trouble with.
{
float sum = 0;
float x;
int check;
int l;
int i;
string Integer;
do
{
cout << "Please enter an integer: ";
getline(cin, Integer);
l = Integer.length();
for (i = 0; i < l; i++)
(isdigit(l));
check = x;
if (check != x || isalpha(x))
{
cout << "You did not enter an integer\n";
}
}
while(check != x || isalpha(x));
while ((isalpha(x)) || (!isdigit(x)));
{
cout <> x;
((isdigit(x)) || (!isalpha(x));
}
sum = sum + x;
while (x != 0)
{
cout <> x;
((isalpha(x)) || (!isdigit(x));
}
sum = sum + x;
}
cout << sum << endl;
return 0;
}
I'm really hoping you can help. This is the most important program to understand have done before the Final as the Final itself is similar to this program, not the same, but similar as far as I've had. We're starting the Final next week and I can only work on this program during school, which is 1:17pm - 2:37pm EST.