This is not part of my assignment, but I would like to figure out how to test the user input to be sure it is an integer. Is there a native function that I can use? If not can some one point me in the right dirrection because I am drawing a blank. At first I thought I would do this by comparing the ascii values but I did not figure out how to implement it. Here is the assignment that is actually finished and working. It compares two arrays to figure out the taxrate of an income. Would like to test the variable aswer.
#include <iostream.h>
#include <stdlib.h>
int main()
{
const int max = 5;
int answer = 0, counta = 0, countb = 0, index = 0;
int income[max] = {0,10000,20000,50000,100000};
int tax[max] = {0,5,10,15,20};
cout<<"What is your income? ";
cin>> answer;
for (counta = 0; counta < max; counta++) {
for (countb = 1; countb < (max + 1); countb++) {
if ((answer >= income[counta]) & (answer <= income[countb])) {
index = counta; }
}
}
cout<<"Your taxrate is "<< tax[index] << "%" << endl;
cout<<"Your taxes are $"<< (tax[index]*.01)*answer <<
endl << endl;
system("PAUSE");
return 0;
}
Thanx