#include #include #include using namespace std; int main() { cout << "Please type your weight in pounds:\n"; double weight {0.00}; cin >> weight; if (!cin) { cerr << "Could not perform input.\n"; return EXIT_FAILURE; } if (weight <= 0.00) { cerr << "Sorry, weight must be positive.\n"; return EXIT_FAILURE; } cout << "How many years will you be doing this diet for? "; int nyears {0}; cin >> nyears; if (!cin) { cerr << "Could not perform input.\n"; return EXIT_FAILURE; } if (nyears <= 0) { cerr << "Sorry, the number of calories must be positive.\n"; return EXIT_FAILURE; } cout << "What is the annual calorie increase rate? "; double rate {0.0}; cin >> rate; if (!cin) { cerr << "Could not perform input.\n"; return EXIT_FAILURE; } if (rate <= 0) { cerr << "Sorry, the calorie increase rate must be positive.\n"; return EXIT_FAILURE; } const double factor {1.00 + .25 * rate}; cout << "year weight\n" << "---- ------\n"; for (int year {1}; year <= nyears; ++year) { weight *= factor; cout << " " << setw(2) << year << " years " << fixed << setprecision(2) << weight << "\n"; } return EXIT_SUCCESS; }