lalalalala
First one: Assume that two int constants,FIRST_YEAR and LAST_YEAR have already been declared and initialized with year values (like 2009, 2014), along with a double variable oil that has been initialized with the number of barrels of oil consumed in Canada in the year given by FIRST_YEAR. Write some code that uses a while statement to print on a line by itself, each of the years from FIRST_YEAR to LAST_YEAR inclusive. On each line, after the year, separated by a colon and a space, print the new value amount of oil, taking into account that each year the oil consumed increases by 20%. This is what I have so far, but it's saying the output is incorrect int x = FIRST_YEAR; while(x <= LAST_YEAR) { oil *= 1.2; cout << x << ": " << oil << endl; x++; }
@bananas
do you have oil defined? What happens when you run your own code with 2009 and 2014?
In case that helps at all
it does, move oil after print
i mean move oil*=1.2 after cout
that worked... why did it need to be after the cout statement?
because you had already increased the percentage and then printed it. It wants you to assume you start with 300, print then increase.
ohh, okay, that makes sense
Join our real-time social learning platform and learn together with your friends!