# CSE 232 Programming Project #1 solved

\$35.00

Category:

## Description

Assignment Overview
This project focuses on some mathematical manipulation. It is worth 5 points (0.5% of your
overall grade). It is due Monday, September 10th before midnight.
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 degreesF/year and the intercept is 34.3491 degreesF. Using this
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:
a. 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.
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.
Assignment Notes:
1. We might as well try to make the output somewhat readable. You can look this up in the text
or on the internet, but you can use the following modifiers that affect how numbers print.
a. cout << fixed; Elements will be printed as floating point numbers (ex 123.456). Use this for the project. b. cout << scientific; Elements will be printed in scientific notation (ex 1.23456 x 102). This is an alternative but not what we want for this project. c. cout << setprecision(2); Floating point numbers will have 2 values after the decimal point and will be rounded, (123.46). To make this work we need another include, and that is #include
Provide the include and use setprecision(2) for this project.
d. Thus cout << fixed << setprecision(2) << 123.4567 << endl; will print 123.46 2. The following statement will read two variables off of the same, space separated line. It is an example of chaining input: … long lng; double dbl; cin >> 1ng >> dbl;

You can also do it on separate lines. Your choice

cin >> lng;
cin >> dbl;

3. If you #include you get access to the std::round function. The
std::round function takes as an argument the number to be rounded and returns the
nearest integral value (see https://en.cppreference.com/w/cpp/numeric/math/round for full
details)
4. There are 4 tests provided. The first is a file-exists test to make sure you got the directory
issue correct, the remaining three are input-output tests.
5. You do not have to check for bad input values. In general, we will explicitly indicate the
errors we are looking for, but for now we are not checking for input errors.
6. It gets irritating to type in 2 numbers every time you test. To get around this, you can use a
handy trick off the command line. You can create a file with the 2 input values (on a single
line, they need to be space separated, on 2 different lines is also fine). You can redirect the
file to your main program. With that file in the same directory as the compiled a.out, you
can do: