I have been presented with the following practice question on a c++ course I'm taking. I have no access to the teacher so I do not know who to turn to
The exercise says:
2.7: Ocean Levels
Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a program that displays
The number of millimeters higher than the current level that the ocean’s level will be in 5 years,
The number of millimeters higher than the current level that the ocean’s level will be in 7 years,
The number of millimeters higher than the current level that the ocean’s level will be in 10 years,
Output labels: Each value should be on a line by itself, preceded by the a label of the form:
In X years the ocean's level be higher by Y millimeters.
where X is the number of years (5, 7 or 10) and Y is the value you calculate.
----------------------------------------------------------------------------------------------
When I submit my code to the computer course software it gives me a logical error. The program runs fine when I execute but obviously its not the right answer. Is there something I'm missing as far as the math formula goes? Please help
Here is the code I have so far:
Code:#include <iostream> using namespace std; int main() { double fiveYears, sevenYears, tenYears; fiveYears = 5 * 1.5; sevenYears = 7 * 1.5; tenYears = 10 * 1.5; cout << "In 5 years the ocean's level be higher by " << fiveYears << " millimeters." << endl; cout << "In 7 years the ocean's level be higher by " << sevenYears << " millimeters." << endl; cout << "In 10 years the ocean's level be higher by " << tenYears << " millimeters." << endl; system("PAUSE"); return 0; }