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

Using C++ Thanks The Problem Global warming discussions are a hot topic these da

ID: 3744681 • Letter: U

Question

Using C++ Thanks

The Problem Global warming discussions are a hot topic these days. A paper in early August 2018 called Trajectories of the Earth System in the Anthropocene" predicted that if the global temperature increase by 7 degrees Fahrenheit, the change would be irreversible. We are going to explore the change in global temperature versus year based on a simple linear model and make some predictions as to when this might occur Some Background Hopefully you remember that a linear model is created by specifying a slope and an intercept where you can use the equation y - slope *x + intercept (y is the temp, x is the year). I gathered (see spreadsheet) the average global temp in degrees Fahrenheit, 1880-2012, and fit a linear model to it. The slope is 0.01173 degreesFlyear and the intercept is 34.3491 degreesF. Using thi:s information, you will write a program that does as follows. Program Specifications Your program will do the following 1. Take as input two values a. a year, as a long b. a slope, as a double 2. Print three results Print the temperature for the year read in above based on the slope and intercept provided in the Background section. Print it as a double of precision 2 a. b. Print the year when, given the temperature calculated in a. above, a temperature 7 degrees greater will occur again using the slope and intercept provided in the Background. Print it as a rounded long c. Print the year when, given the temperature calculated in a. above, a temperature 7 degrees greater will occur using the second input, a new input slope, and the intercept provided in the Background. Print it as a rounded long Deliverables proj01/proj01.cpp . The name of the directory is proj01, the name of the file you turn in should be exactly proj01.cpp in a directory named proj01. This is how all projects will be turned in: in a directory containing a file(s). To help with this, we will check that this is true with the first test case in Mimir. Just like the lab, you must click on proj01 within "Project 01 - model of global warming" to submit the file. Not the file proj01.cpp, the directory proj01 in which the file proj01.cpp is contained.

Explanation / Answer

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
double slope=0.01173,intercept=34.3491; //for storing background slope and intercept
double inSlope , temp; //inslope is for taking slope from user and temp for storing temperature
long year; //for taking value of year from user
cin>>year>>inSlope; //inputting year and user's slope
temp=slope*year+intercept; //calculating temp using background slope and intercept
cout<<fixed<<setprecision(2)<<temp<<endl; //Displaying temp according to the question
temp=temp+7.0; //incrementing temp by 7 degrees for steps 2 and 3
year=(temp-intercept)/slope; //calculating year using background slope, intercept and above calculated temp(using the given formula)
year=round(year); //rounding year to nearest integer value
cout<<year<<endl; //displaying year
year=(temp-intercept)/inSlope; //calculating year using background intercept, user's slope and above calculated temp
year=round(year);
cout<<year<<endl; //displaying this year again
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote