School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,108 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,042 people online right now. Registration is fast and FREE... Join Now!




Pseudocode- help with the logic

 

Pseudocode- help with the logic

2face323

21 Oct, 2009 - 05:48 AM
Post #1

New D.I.C Head
*

Joined: 21 Oct, 2009
Posts: 1

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.)


User is offlineProfile CardPM
+Quote Post


janne_panne

RE: Pseudocode- Help With The Logic

21 Oct, 2009 - 06:14 AM
Post #2

D.I.C Addict
****

Joined: 9 Jun, 2009
Posts: 531



Thanked: 107 times
My Contributions
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.

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
}


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 12:41PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month