Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

HELP Needed with pseudo code Java

pseudo code pseudocode

  • Please log in to reply
8 replies to this topic

#1 Gman

Gman

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts
  • Location:Donegal, Ireland
  • Learning:Java, C#, PHP, (Visual) Basic, JavaScript, Assembly, Others

Posted 09 November 2011 - 08:01 AM

Hi All

As you may know by now i am new to java ( 1st year student ). Can some please help and explain pseudo code or tell me where i can find some tutorial so i can learn it... i had a look at a few pass paper exam and found this question on it. At this moment i would not know how to do it never mine start it. :confused:

Hopefully the answers will help someone else in the near future!!!!

Imagine that you have been asked to write a program that will
input a noon day temperature for each day in each month of the
year and output the average temperature for each month and the
average of the year. Develop a pseudo code solution to this problem.
You should show the stages of the development process and state
any assumptions that you make.


Thanks in Advance

Gman

Edited by Gman, 09 November 2011 - 08:04 AM.
Spelling in title.

  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 09 November 2011 - 08:37 AM

Things to think about:
1) how many readings will you need to make?
2) how do you need to group the readings?
3) think about doing this by hand. What would you do to perform this with pencil and paper, in such a way that you could hand the results to someone else?
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 09 November 2011 - 11:17 AM

There is no such thing as a formal specification on pseudocode. Pseudocode is merely well-formed non-ambiguous English statements describing exactly which steps your algorithm will follow. There's nothing to learn in order to write pseudocode.

EDIT:
Here's an example of pseudocode:

Routine: Buy Milk.
Fetch Wallet.
Fetch Car Keys.
Look Outside.
If it looks like rain:
    Fetch Umbrella.
End if.
Go Outside.
If it is raining:
    Open Umbrella.
End If.
Get in Car.
Drive to Store.
Enter Store.
Fetch Milk.
Go to Checkout Station.
Pay Cashier.
Leave Store.
Get in Car.
Drive Home.
... (continued)

You can be as detailed as you like, and as thorough as you like.
  • -1

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#4 Gman

Gman

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts
  • Location:Donegal, Ireland
  • Learning:Java, C#, PHP, (Visual) Basic, JavaScript, Assembly, Others

Posted 09 November 2011 - 12:51 PM

Thanks i will give that a go, so just write out each step by step.

Things to think about:
1) how many readings will you need to make?
2) how do you need to group the readings?
3) think about doing this by hand. What would you do to perform this with pencil and paper, in such a way that you could hand the results to someone else?



---------- Post added at 12:51 PM ---------- Previous post was at 12:47 PM ----------

There is no such thing as a formal specification on pseudocode. Pseudocode is merely well-formed non-ambiguous English statements describing exactly which steps your algorithm will follow. There's nothing to learn in order to write pseudocode.

EDIT:
Here's an example of pseudocode:

Routine: Buy Milk.
Fetch Wallet.
Fetch Car Keys.
Look Outside.
If it looks like rain:
    Fetch Umbrella.
End if.
Go Outside.
If it is raining:
    Open Umbrella.
End If.
Get in Car.
Drive to Store.
Enter Store.
Fetch Milk.
Go to Checkout Station.
Pay Cashier.
Leave Store.
Get in Car.
Drive Home.
... (continued)

You can be as detailed as you like, and as thorough as you like.


Thanks for that gregwarner, i defo have a bit more knowledge of Pseudocode.

Gman:)
  • 0

#5 Gman

Gman

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts
  • Location:Donegal, Ireland
  • Learning:Java, C#, PHP, (Visual) Basic, JavaScript, Assembly, Others

Posted 12 November 2011 - 01:23 PM

Things to think about:
1) how many readings will you need to make?
2) how do you need to group the readings?
3) think about doing this by hand. What would you do to perform this with pencil and paper, in such a way that you could hand the results to someone else?


Ok i tried to tackle it and no joy , i think i need 3 readings temp, day, month, after that i dont know what way to go about it.

Help :confused::confused:
  • 0

#6 fread

fread

    Programming God

  • Senior Member
  • PipPipPipPipPipPip
  • 897 posts
  • Location:Trinidad and Tobago
  • Learning:C, Java, C++, C#, PHP, Python, PL/SQL

Posted 12 November 2011 - 02:23 PM

Hint: Decide on how you are going to store the data. Take note of the amount of data you need to store.
  • 0

#7 Gman

Gman

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts
  • Location:Donegal, Ireland
  • Learning:Java, C#, PHP, (Visual) Basic, JavaScript, Assembly, Others

Posted 14 November 2011 - 01:18 PM

here is what i have come up with, would you be able to do the same program by reading this.:confused:

get Temperature
store temperature for each day in each month
calculate how many days in each month
calculate average temperature for each month
find how many months in year and
calculate average temperature for each year

Display average temperature for each month and the average of the year.



Gman
  • 0

#8 fread

fread

    Programming God

  • Senior Member
  • PipPipPipPipPipPip
  • 897 posts
  • Location:Trinidad and Tobago
  • Learning:C, Java, C++, C#, PHP, Python, PL/SQL

Posted 14 November 2011 - 03:21 PM

You are probably missing some of the mechanics. Like, get Temperature; that suggest a method to get all the different temperature values. Then you say store temperature. But are those two lines working together? Mechanics and details of the pseudo code depend on interpretation. Looking at the problem, and the code I could get enough to produce language specific code to solve the problem, others may not. To be safe you should include a bit more detail in terms of which lines goes before the other. Also I think it is safe to say a year is 12 months. A good pseudo code should leave a clear picture of what needs to be done and in what order it should be done in the mind of the reader, without getting into to much technical stuff.
  • 0

#9 Gman

Gman

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts
  • Location:Donegal, Ireland
  • Learning:Java, C#, PHP, (Visual) Basic, JavaScript, Assembly, Others

Posted 15 November 2011 - 02:54 AM

You are probably missing some of the mechanics. Like, get Temperature; that suggest a method to get all the different temperature values. Then you say store temperature. But are those two lines working together? Mechanics and details of the pseudo code depend on interpretation. Looking at the problem, and the code I could get enough to produce language specific code to solve the problem, others may not. To be safe you should include a bit more detail in terms of which lines goes before the other. Also I think it is safe to say a year is 12 months. A good pseudo code should leave a clear picture of what needs to be done and in what order it should be done in the mind of the reader, without getting into to much technical stuff.


Thanks fread i will add a bit more them and post later, just need to stop thinking about java when writing pseudo code and put it in english.:confused:

gman
  • 0





Also tagged with one or more of these keywords: pseudo code, pseudocode

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download