Solution Review: Oven is Ready!

In the following lesson, we will go over the solution of the challenge: Oven is Ready!

We'll cover the following

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.

Press + to interact
var count = 0
var temperature = 300
while (temperature<375) {
temperature += 25
count +=1
}
println(count)

Let’s move on to the next control structure: for.