Answer:
Here is the C++ code:
#include <iostream> //for utilizing input and output functions
using namespace std; //for defining objects cin cout
int main(){ //beginning of the main function
double risingLevel; //declares a variable of type double to store the rising level
cin>>risingLevel; //captures the risingLevel input from the user
cout<<"Level: "<<risingLevel<<endl; //outputs the rising level
cout << "Years: 5, Rise: " << risingLevel * 5<<endl; //outputs the increase in ocean level over 5 years
cout << "Years: 10, Rise: " << risingLevel * 10<<endl; //outputs the increase in ocean level over 10 years
cout << "Years: 50, Rise: " << risingLevel * 50<<endl; //outputs the increase in ocean level over 50 years
}
Explanation:
The functioning of the program is as follows:
Supposing the user inputs a rising level of 2.1, then,
risingLevel = 2.1
At that point, the first print statement (cout):
cout<<"Level: "<<risingLevel<<endl; outputs the value of risingLevel to the display. Therefore, this line shows:
Level: 2.1
Next, the program proceeds to the following statement:
cout << "Years: 5, Rise: " << risingLevel * 5<<endl;
which calculates the increase in ocean levels for a duration of 5 years using the equation:
risingLevel * 5 = 2.1 * 5 = 10.5
It subsequently shows the calculated result on the display. So, this line shows:
Years: 5, Rise: 10.5 Then, the control shifts to the next statement:
cout << "Years: 10, Rise: " << risingLevel * 10<<endl;
that computes the rise in ocean levels over a span of 10 years using the equation:
risingLevel * 10 = 2.1 * 10 = 21
It then showcases the calculated figure on the output screen. Thus, the output is:
Years: 10, Rise: 21
Next, the program control progresses to this statement:
cout << "Years: 50, Rise: " << risingLevel * 50<<endl;
which determines the rise in ocean levels for a duration of 50 years using the equation:
risingLevel * 50 = 2.1 * 50 = 105
This then displays the computed result on the output screen, leading to the output:
Years: 50, Rise: 105 Consequently, the complete output from the program will be:
Level: 2.1 Years: 5, Rise: 10.5
Years: 10, Rise: 21
Years: 50, Rise: 105