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

Assume that two int constants, FIRST_YEAR and LAST_YEAR have already been declar

ID: 3654305 • Letter: A

Question

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%.

Explanation / Answer

you can not change a constant int, and FIRST_YEAR is a constant int. You need to declare a new variable in its spot, such as 'i'. This code will work: int i; i = FIRST_YEAR; while (i