#include #include #include // for system_clock #include // for localtime using namespace std; void throwPass(int& yards, int& completions, int& attempts); int main() { const auto now {chrono::system_clock::now()}; const time_t t {chrono::system_clock::to_time_t(now)}; const tm *const p {localtime(&t)}; // Display current date for flavor const int y {p->tm_year + 1900}; const int m {p->tm_mon + 1}; const int d {p->tm_mday}; cout << "Game Day: " << m << "/" << d << "/" << y << "\n"; cout << "How many passes do you want to throw? "; int passes {0}; cin >> passes; if (!cin) { cerr << "Sorry, that wasn't a number.\n"; return EXIT_FAILURE; } if (passes < 1) { cerr << "You must throw at least one pass.\n"; return EXIT_FAILURE; } int yards {0}; int completions {0}; int attempts {0}; // Simulate each pass for (int i {0}; i < passes; ++i) { throwPass(yards, completions, attempts); } cout << "\nFinal Stats:\n" << "Attempts: " << attempts << "\n" << "Completions: " << completions << "\n" << "Total Yards: " << yards << "\n"; return EXIT_SUCCESS; } // Simulate a single pass attempt void throwPass(int & yards, int & completions, int & attempts) { ++attempts; const int successChance {rand() % 100}; if (successChance < 65) { const int gained {rand() % 40 + 5}; // 5–44 yards yards += gained; ++completions; cout << "Pass complete! Gained " << gained << " yards.\n"; } else { cout << "Incomplete pass.\n"; } }