Question: Rewrite this program using nested if-else statements #include using namespace std; /* Estimates dog's age in equivalent human years. Source: www.dogyears.com */ int main() {
Rewrite this program using nested if-else statements
#include
/* Estimates dog's age in equivalent human years. Source: www.dogyears.com */
int main() { int dogAgeYears;
cout << "Enter dog's age (in years): " << endl; cin >> dogAgeYears;
switch (dogAgeYears) { case 0: cout << "That's 0..14 human years." << endl; break;
case 1: cout << "That's 15 human years." << endl; break;
case 2: cout << "That's 24 human years." << endl; break;
case 3: cout << "That's 28 human years." << endl; break;
case 4: cout << "That's 32 human years." << endl; break;
case 5: cout << "That's 37 human years." << endl; break;
default: cout << "Human years unknown." << endl; break; }
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
