Pseudocode- help with the logic

Page 1 of 1

1 Replies - 4573 Views - Last Post: 21 October 2009 - 07:14 AM

#1 2face323

Reputation: 0
• Posts: 1
• Joined: 21-October 09

Pseudocode- help with the logic

Posted 21 October 2009 - 06:48 AM

I am having a real tough time understanding the logic involved in writing the pseudocode for the following problem. Any help would be greatly appreciated and beneficial. If someone could please show me an example of how they would write the pseudocode for this problem, I could learn from the example. Please help!!

The village of Ringwood has taken a special census. Every census record contains a household ID number, number of occupants, and income. Ringwood has exactly 75 households. Village statisticians are interested in the median household size and the median household income. Develop the logic for a program that determines these figures. (Remember, a list must be sorted before you can determine the median value.)

Is This A Good Question/Topic? 0

Replies To: Pseudocode- help with the logic

#2 janne_panne

• WinRT Dev

Reputation: 428
• Posts: 1,047
• Joined: 09-June 09

Re: Pseudocode- help with the logic

Posted 21 October 2009 - 07:14 AM

I don't know if you have some special rules for writing the pseudocode but this is what I would do. Not very specific but I don't think pseudocode needs to be, otherwise it would already be complete code.

```
class Village {
Household[75]

function GetMedianSize() {
sort by size;
return GetMedian()
}

function GetMedianIncome() {
sort by income;
return GetMedian()
}

function GetMedian() {
return median of households
}

function Sort(by income / by size) {
sort array by argument
}
}

class Household {
ID : int
numOfOccupants : int
income : double
}

function main() {
Create new Village
Fill village's household information
calculate village's median of size
calculate village's median of income
}

```