@nuts @ultrilliam
I already finished the question, just don't understand why the solution is what it is
I guess my main question would be why isn't it k<=?
<= is less then or equal too, while < is less then
but it wants 97, so while k is less than 97, it would only do 96?
Correct, while it would go to 97 with less then or equal to
couple more loops if you don't mind?
I just read the question... wait... what?
it would only go to 96, yet it counts that as right ok then
yep, and it counts <= as wrong
hold that thought, I'm going to go put some cookies in the oven
I know after each year, there'll be something like `oil*1.2`, but I have no idea how to do what they want for the first year to last year thing
`oil = oil*1.2` `cout << something to do with the years << ": " << oil;` something like that maybe? or am I totally off....
@nuts you wanna do it, I somehow got stuck doing a physics assignmnet
int x; while(FIRST_YEAR <= x || x <= LAST_YEAR) { oil *= oil * 1.2; cout << x << ": " << oil; x++; } did this, and it's almost correct Remarks: ⇒ When executed, your code tried to create an excessively large file. A common cause for this is an infinite loop. Carefully check the condition and the loop body of any loop that does output. More Hints: ⇒ You almost certainly should be using: =
i would but i needa sleep :(
;-;
you used a or statement ```javascript while(FIRST_YEAR <= x || x <= LAST_YEAR) {} ``` while x is greater then x or less then last year it will always evaluate to true, you should be using and (&&)
@sleepyjess
oooohhhhh, got the 2 confused...
also ``` oil *= oil * 1.2; ``` here is your second issue you're multiplying it twice you should either be doing ``` oil *= 1.2; ``` or ``` oil = oil * 1.2; ```
okay, changed that to oil *= 1.2, but still getting the same error message
try ``` oil = oil * 1.2; ``` then?
no issue with the oil statement, it got mad when I tried that way lol
hm, that's the only issue I see *scratching head*
int x; while(FIRST_YEAR <= x && x <= LAST_YEAR) { oil *= 1.2; cout << x << ": " << oil << endl; x++; } that's what I have currently
something to do with the colon maybe?
wait, is it saying oil isn't even output? :thinking_face:
yep, saying nothing is being outputed
I'll just email prof in the morning...
give me a sec
Yea, let's postpone those until tomorrow, *continues to figure this out* this would be so much easier of my visual studio installation was working
*re-reads instructions*
ooooooh
>x isn't defined
(as a number)
huh?
Figured it out
didn't I define it with the `FIRST_YEAR <= x && x <= LAST_YEAR`?
Why did you define x? ``` int x; while(FIRST_YEAR <= LAST_YEAR) { oil *= 1.2; cout << ": " << oil << endl; FIRST_YEAR++; } ```
if my intuition is right
because it wants the year on each line
Yes, but first year is already defined
ok
wait, it says nothing about that
it just says that each year it increases by 20%
(hence the 1.2)
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,
ah "after the year" in that case
``` int x; while(FIRST_YEAR <= LAST_YEAR) { oil *= 1.2; cout << FIRST_YEAR << ": " << oil << endl; FIRST_YEAR++; } ```
wait, why am I still defining x in that
```cpp while(FIRST_YEAR <= LAST_YEAR) { oil *= 1.2; cout << FIRST_YEAR << ": " << oil << endl; FIRST_YEAR++; } ```
Does that wokr?
work?*
got it, then I got this
```cpp int x = FIRST_YEAR ; while(x <= LAST_YEAR) { oil *= 1.2; cout << x << ": " << oil << endl; x++; } ```
the stdout will still be wrong tho, hm, it's at least outputting something now though
yep, still says stdout is wrong
>_<
hmmm
@nuts any idea why this is still wrong?
Join our real-time social learning platform and learn together with your friends!