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

c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether...
c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether the user passed or failed a test. The program will ask the user to input the following: Maximum Test Score - the maximum total scores in the test. Percent Pass Score - the minimum percent scores required to pass the test. User Test Score - the actual scores obtained by the user in the test. From the above input values, the program will compute...
1. Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and...
1. Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" if isBalloon and isRed are both true. Print "Not a balloon" otherwise. End with newline. import java.util.Scanner; public class RedBalloon {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       boolean isRed;       boolean isBalloon;       isRed = scnr.nextBoolean();       isBalloon = scnr.nextBoolean();       /* Your solution goes here */   ...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT