Task
In this challenge, you were provided with the initial temperature of an oven. The oven needed to be 375o for it to be ready. You checked on it after some time and increased it by 25o if the oven had not reached the required 375o.
Solution
Let’s go over the solution step-by-step.
- The first thing you had to figure out is that the program must run until the oven reaches 375o. This means we require a while loop which had the condition:
while (temperature < 375)
- Next, you had to increase the temperature by 25o and increment
count
by 1.
temperature += 25
count +=1
You can find the complete solution below:
You were required to write the code from line 4 to line 7.
var count = 0var temperature = 300while (temperature<375) {temperature += 25count +=1}println(count)
Let’s move on to the next control structure: for
.