Daily life magazine wants an analysis of the demographic characteristics its readers. The marketing department has collected reader survey records containing, the age, gender, maritial status, and annual income of the readers. Design an application that allows a user to enter reader data and, when data entry is complete produces a count of readers by age groups as follows: under 20, 20-29, 30-39,40-49, and 50 and older

6 Years
Discussion Span
Last Post by Nick Evan

Pseudo-code is a design tool. Design starts with asking questions - any questions that help you understand the design are good questions. Who is this for, what does it do? How do they use it? How often do they use it? What sorts of things do they use it with? What sorts of things will they want to do with it in the future?

So, some questions for your specific application might be: Who is using this, and what are they doing with it? What does it look like when they start it up? What do they want to be able to do?

The answers to these will be pretty simple, because this is a pretty simple application, but they will tend to define what you need to write down as pseudocode.

Is the person going to be entering a lot of data? Probably don't want to keep asking them "Do you want to enter another?" repeatedly - instead, you'll use a sentinel value to signal end of input. Or, if you're using a GUI, provide a "done" button.

Are the inputs discrete values chosen from a set, or are they free-entry, or is there a mix? (marital status would probably by chosen from a set, age would probably be free entry, etc.)

Okay, when you've done all that, you start to know what you're going to do, so write it down.

Probably it'll end up being a loop. Perhaps you want to have a start-up notice "Welcome, enter data, type 'Q' to quit, hit return to start" first.

So that would be:

print startup message
wait for keyboard input
while (not finished)
  // here's where you can get started...
}  // end input loop

print output


Oh, wait. Where do we get the output from? I guess you'd better figure out how you're going to do that. Do you calculate it during the input loop, or is it better to store the values and then calculate? Why?

Hope that helps you get started...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.