#include #include using namespace std; int main() { int deduction[] { 30, //0 dependents 50, //1 dependent 65, //2 dependents 95, //3 dependents 105, //4 dependents 120 //5 dependents }; int n {size(deduction)}; //the number of elements in the array cout << "How many dependents do you have? "; int dependents {0}; cin >> dependents; if (!cin) { cerr << "Input failed.\n"; return EXIT_FAILURE; } if (dependents < 0) { cerr << "Must be a non-negative number.\n"; return EXIT_FAILURE; } else if (dependents >= n) { cout << "You can deduct 124 dollars.\n"; } else { cout << "You can deduct " << deduction[dependents] << " dollars.\n"; } return EXIT_SUCCESS; }