Yet another newbie hoping for a little bit of help.
Despite reading a lot of theory about for and while loops, i realised that all this theory doesn't help me with exercises. I struggle every single time i have to use loops, because i can not simply understand how to choose the correct loop.
For example this task:
It takes b minutes for mum to make the first dish. It takes k minutes to make the second dish. And it takes k minutes longer to make the third dish, compared to the second dish etc.. (So assuming b = 10 and k = 3, it takes 10 minutes for the first dish, 13 minutes for the second dish, 16 minutes for the third dish etc.. You get the idea ;)) Write a program, that would calculate, how many dishes will mum make before her kids comeback. Kids will come back after t minutes. All data is int type. To check: If b = 17, k = 3, t = 65, mum would make 3 dishes.
At first glance, it's a pretty simple task. But i got stuck at the moment i had to use a loop. I tried to create a for loop, later i tried to use while loop - no result.
The problem is, i don't know what condition shall i choose, what should the variable initialization be etc..
Simply said, i just write: for (int i =
And then i get stuck.
Any help, either with the given task, or with "picking the right loop overall" would be really appreciated, since this is such a simple thing that i can't get over.
Thanks in advance : )