Java example - for loop and conditionals from course exercise
Archive - Originally posted on "The Horse's Mouth" - 2015-02-16 18:24:37 - Graham EllisMost of our training modules have exercises at the end (sometimes in the middle too) to help delegates checkpoint their understanding, and to give the tutor feedback as to how they're doing, and what coding techniques and habits they're bringing from other languages. With the exercises, there's rarely a "right" way of doing it, and over the years I've added a number of sample answers to our web site - to the extent that there are commented samples for most of the exercises on the courses. But just occasionally we find one that isn't ... and that happened today.
Here's the question:
One hundred Singapore Dollars are worth 56.54 US Dollars.
Write a program to produce a conversion table.
The first column should be a number of US dollars 10, 20, 30 and so on up to 100.
The second column should be the number of Signapore Dollars that it's worth.
You are visiting Singapore and you see a teapot in a shop window at 75 Singapore Dollars.
Extend your previous program, adding a third column on the right of your output that
says either "YOU CAN AFFORD THE TEAPOT" or "YOU DON'T HAVE ENOUGH MONEY FOR THE TEAPOT"
And source of the sample answer - [here].