brandon mac wrote:Okay so from my previous post and what I have learned so far from asking for help on here I shall start with english instead of what I think should be written for code.
Well, that's a good start but, as Campbell says, when you do so you should concentrate on
what you need to do, not
how you're going to do it. A lot of what you've written is
Java converted to English, when what you need to do is the exact opposite.
How about this:
Task: Convert cups to quarts
Steps:
1. Get a number of cups.
2. Convert the number of cups to a number of quarts.
3. Display the number of quarts.
No Java, no mention of doubles or integers, or declarations, simply a statement of the steps required to complete the task. Notice also that we haven't even said
how we're going to get the 'number of cups', because at this stage
it isn't important.
We can decide whether we get it from the keyboard, or a file, or a GUI component, or indeed just initialise a variable for it,
when we write our program; but that Step 1 tells us that we will probably want a method called something like '
getNumberOfCups()' that returns us a number of some sort.
And if we need to explain things a bit further - eg, what we need to do to convert from cups to quarts - we can break down that Step 2 into sub-steps (or simply add something like "1 quart == 4 cups" to clarify it).
Remember: When describing a solution, avoid thinking about Java. Think about
the problem.
It's possibly also worth mentioning that an awful lot of problems/programs/methods follow a similar
pattern:
1. Get some data.
2. Process it.
3. Display (or return) the results.
It's called the
IPO model, and it's been around pretty much as long as programming languages.
HIH
Winston