Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

zyBooks catalog @ Help/ ACTIVITY34 Mutbranch if else statement Print century Wni

ID: 3879593 • Letter: Z

Question

zyBooks catalog @ Help/ ACTIVITY34 Mutbranch if else statement Print century Wnite an if-else statement with multiple branches. If givenYear is 2100 or greater, print "Distant future" (without quotes) Else, if givenYear is 2000 or greater (2000-2099). print 21st century Else, if givenYear is 1900 or greater (1900-1999) print 20th century Else (1899 or earlier), print "Long ago Do NOT end with newline ·include using nanespace std 4 int main( ) s Int givenYear; 7 givenvear 1776; 9Your solution goes here 1e 11 return 0 12 Run Feedback?

Explanation / Answer

1st run:

#include <iostream>
using namespace std;

int main()
{
   int givenyear;
   givenyear=1776;
   if(givenyear>=2100)
   cout<<"Distant future";
   else if(givenyear>=2000)
   cout<<"21st century";
   else if(givenyear>=1900)
   cout<<"20th century";
   else
   cout<<"long ago";
  
}

Sample output: Long ago

2nd run:

#include <iostream>
using namespace std;

int main()
{
   int givenyear;
   givenyear=1900;
   if(givenyear>=2100)
   cout<<"Distant future";
   else if(givenyear>=2000)
   cout<<"21st century";
   else if(givenyear>=1900)
   cout<<"20th century";
   else
   cout<<"long ago";
  
}

sample output: 20th century

3rd run:

#include <iostream>
using namespace std;

int main()
{
   int givenyear;
   givenyear=2001;
   if(givenyear>=2100)
   cout<<"Distant future";
   else if(givenyear>=2000)
   cout<<"21st century";
   else if(givenyear>=1900)
   cout<<"20th century";
   else
   cout<<"long ago";
  
}

sample output: 21st century

4th run:

#include <iostream>
using namespace std;

int main()
{
   int givenyear;
   givenyear=2200;
   if(givenyear>=2100)
   cout<<"Distant future";
   else if(givenyear>=2000)
   cout<<"21st century";
   else if(givenyear>=1900)
   cout<<"20th century";
   else
   cout<<"long ago";
  
}

sample output: distant future