I am trying to find the median of 3 numbers. I am having trouble figuring out where certain if statements should be. I am only allowed to use if - then and else statements. Also, no || and &&. Here is what I have so far.
if (s < t)
if (f < t)
median = f;
else if (t < f)
median = f;
//(f = first, s = second, t = third)
Could you give me some guidance on how to complete this for s and t? Nested if statements are OK.
I am afraid there is a piece of equipment which is hindering you and it needs to be removed from your attention so as not to distract you. The simplest way to do that is to power down your computer.
Get a sheet of paper and a pencil and an eraser (the latter probably the most important) and write down how you would do it without a computer. Once you have that, you will probably find it easy to turn into code.
There are six possible permutations. First, you need to figure out what those six are (listing them). And second, you need to map the path to all six of them. Mapping it out on paper was how I was able to do it.... and quite frankly, I would be very impressed if someone can do it without mapping it out first (and simply coding).