Nail/Head Campbell. (See, we always agree!campbell wrote: It's a shame your lecturer hasn't put all this into better context for you, because it is possible to gradually develop an interest in computer programming without the in-at-the-deep-end style being used here!
I agree you should indeed do your own coursework, you will never learn how to do it for yourself in future if the help is delivered verbatim - but Graeme and Fergus I take my hat off to you both for what you knocked out and your intentions are totally sound. Very much in the spirit of this group in fact. I particularly liked Fd's suggestion for you to get googling and researching...just don't copy the stuff you find, play with it and make it your own.

It's no coincidence that Tom and I (dare I say two reasonably intelligent individuals) both needed help with the same module at the same uni; it's a very poor introduction to programming. The CompSci crowd get to focus on learning C all week, but the engineers are supposed to pick it up along side their main subject with a teeeeny fraction of the tutoring and time. It turns programming into a frightening distraction instead of the fascinating subject it should be.
My posted solution works, but is not hand-inable. There's more to be done. Validation of input, error handling, commenting, increasing the precision, renaming everything...
A wee bit of SE tutoring will go a long way, so Tom, do get in touch with Robin or I or anyone else who has offered.