I have to write a program for my class the makes to arrays on with a tax rate and another with a income. The user inputs a gross income and the program searches the income array to find out what range the users income is in and then multiplies the users gross income by the related tax rate from the tax rate array.
In my program i searched the income array as is in the program, but the way i did it i had trouble getting the last element of the array to be used properly so i added the second if block. What i would like to know is there another way to do this that is a little cleaner, but still looks kind of the same.
- but don't use this x=5; a simple break; statement is less baffling
- shouldn't Taxes be a double type?
- and, yeah system("pause"); shouldn't be used (yada-yada), ref: http://www.cplusplus.com/forum/beginner/1988/
@Line 18:
Be careful here, as you're running the risk of a segmentation fault... remember that x starts at 0 and goes to SIZE - 1, which by the way is the range of possible (valid) indexes for your entire array.
Generally arrays don't like indexing their neighbors in front of them. They don't usually get along, and the compiler has to get involved... that's always ugly.