Question: Integers expMonth and expYear are read from input. Complete the try block to output Passport expires on followed by expMonth, /, and expYear with
Integers expMonth and expYear are read from input. Complete the try block to output "Passport expires on " followed by expMonth, "/", and expYear with error checking:
- If expMonth is < 1 or > 12, throw a runtime exception with the message "Month must be between 1 and 12".
- If expYear is < 2028, throw a runtime exception with the message "Year must be at least 2028".
Ex: If input is 10 2038, then the output is:
Passport expires on 10/2038 Ex: If input is 28 2038, then the output is:
Error: Month must be between 1 and 12 Ex: If input is 10 2015, then the output is:
Error: Year must be at least 2028 THE CODE BELOW CANNOT BE CHANGED
#include
int main() { int expMonth; int expYear;
cin >> expMonth; cin >> expYear;
try {
/* Your code goes here */
} catch (runtime_error& excpt) { cout << "Error: " << excpt.what() << endl; }
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
