Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know this may sound a little nutty, but it works: Imagine your user input as a little animal and you have set a trap for it. You need to catch the animal and do something to it. For our animal lovers' sake, let's say you need to catch it, tranquilize it, weigh it, and put a radio collar on it and then release it relatively unharmed provided it is of type Cougar. So, our trap is a multi-function trap. Whatever enters it, a value will be produced. </p> <p>WHAM!!! Something is in the trap. Luckily, our trap is automatic. If it doesn't land a float value, then the trap opens and it leaves. It isn't a Cougar.</p> <p>OK, the trap is still closed. It must be a Cougar. We can work on it.</p> <p>Now, we ask the guy wearing the Banana Republic gear with the big Nikon around his neck for some help. We have this Float value in the trap. Now, we ask the Scientist in the Banana Repubic gear what our number means.</p> <p>"Hey, Scientist Guy, what does the number in our trap mean?"</p> <p>If "It's the length", he answers: </p> <pre><code>This is the length of the Cougar in feet, I need it it converted to meters... This is the length of the Cougar in meters, I need it it converted to feet... </code></pre> <p>If "it's the weight", he answers: </p> <pre><code>This is the weight in pounds, I need it converted to kilos... This is the weight in kilos, I need it converted to pounds... </code></pre> <p>You may find that, when you think about it, your Teacher was asking 'how do you set up the problem'? In other words, by asking the user for the value first, you can cut down on the amount of questions the program has to answer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload