Question

In: Computer Science

Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future"...

Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Else, if givenYear is 2001 or greater (2001-2100), print "21st century". Else, if givenYear is 1901 or greater (1901-2000), print "20th century". Else (1900 or earlier), print "Long ago". Do NOT end with newline C++

Solutions

Expert Solution

Program Code Screenshot:

Sample Output:

The screenshots are attached below for reference.

Please follow them for proper output.

Please upvote my answer. Thank you.

Program code to copy:

#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter year:";
cin>>n;//read year from user
if(n>=2101){//compare the value and print appropriate output
cout<<"Distant future";
}
else if(n>=2001){
cout<<"21st century";
}
else if(n>=1901){
cout<<"20th century";
}
else{
cout<<"Long ago";
}

return 0;
}


Related Solutions

b)Everything else equal, which annuity has the greater future value: an     annuity or an annuity due?...
b)Everything else equal, which annuity has the greater future value: an     annuity or an annuity due? Why? c) What is the difference between an ordinary annuity and an annuity due d) All else equal, which annuity has the greater present value: an ordinary annuity or an annuity due? Why?
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Note: These...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Note: These activities may test code with different test values. This activity will perform three tests, with userInput of "That darn cat.", then with "Dang, that was scary!", then with "I'm darning your socks.". See "How to Use zyBooks". . Also note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If userInput is "That darn cat.", then output is: Censored Ex: If userInput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message. #include <iostream>...
Print "Censored" if userInput contains "darn", else print iserInput. End with newline. Ex: If userInput is...
Print "Censored" if userInput contains "darn", else print iserInput. End with newline. Ex: If userInput is "That darn cat", then output is:
Write anoutput(number)functionthat printsout information according to the requirements below.-If numberis a multiple of 3and 4, print"Multiple...
Write anoutput(number)functionthat printsout information according to the requirements below.-If numberis a multiple of 3and 4, print"Multiple of 3 and 4". -If numberis onlya multiple of 4, print "Multiple of 4".-If numberis onlya multiple of 3, print "Multiple of 3". -If numberis not a multiple of 3or 4, print "Not a multiple of 3or 4" >>output(12)'Multiple of 3 and 4'>>>output(8)'Multiple of 4'>>>output(5)'Not a multiple of 3 or 4
(Java Zybooks) Print "Censored" if userInput contains the word "darn", else print userInput. End with newline....
(Java Zybooks) Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If userInput is "That darn cat.", then output is: Censored Ex: If userInput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message....
Write an if-else statement for the following: If numDifference is less than -20, execute totalDifference =...
Write an if-else statement for the following: If numDifference is less than -20, execute totalDifference = -25. Else, execute totalDifference = numDifference. import java.util.Scanner; public class NumberDifference {    public static void main (String [] args) {       int totalDifference;       int numDifference;       Scanner scnr = new Scanner(System.in);       numDifference = scnr.nextInt(); // Program will be tested with values: -19, -20, -21, -22. //solution goes here//       System.out.println(totalDifference);    } }
An MNC expects to sell fixed assets it utilizes in Europe in the distant future. In...
An MNC expects to sell fixed assets it utilizes in Europe in the distant future. In order to hedge the sale of these assets in the distant future, the MNC could create a(n) ____ that ____ the expected value of the assets in the future. asset; matches asset; exceeds liability; matches liability; is less than
You are asked to work as an astrobiologist in the distant future. On Neptune’s moon Triton,...
You are asked to work as an astrobiologist in the distant future. On Neptune’s moon Triton, you find a species of terrifying and giant crustacean-like aliens that appear to live in completely isolated populations within the nitrogen ice valleys on the surface. As a famed xenobiologist that specializes in population genetics, you decide to compare and contrast two of these isolated populations. Specifically, you are interested in the locus terror​​, which comprises three alleles T1, T2, and T3. Using state...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last two digits of any 4 digit number stored in an integer variable n.         For example, given int n = 5623, print 56    23. 6. Write  C++ statements that will align the following three lines as printed in two 20 character columns. Name                                                 Years President Abraham Lincoln                                 1860-1865 Thomas Jefferson                               1801-1809 7.  Write a C++ statement or statements that will Output if a string has a length greater than 10, equal...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT