• 0

[Java] Guide how to write pseudocode in Java


Question

6 answers to this question

Recommended Posts

  • 0

^

funny as pseudo means not real :)

sorry I dont know any websites or anything that tell you how to write pseduo code.

generally you dont need one. just write the program logic

method that does something

doSomething( aNumber)

{

while number is less than 5 {

finalNumber = aNumber + 100

aNumber = aNumber - 1

}

return finalNumber

}

}

there is no real hard and fast rules to follow when writing pseudo code except that it should be readable. for example using "for (int i =0; i < 10; i++)" is not really readable.

you would write while (iterator less than 10) ...etc but really anything can be acceptable in pseduo

well that is my 2 cents on it.

  • 0
  Winston said:
It's essentially the same structure, but when you do condition statements or print anything u write it like english

for example:

while(count is less than count variable)

{

Print "Hello"

}

586806962[/snapback]

hmmm.. yes , i know but i still need more exmaple

for example how you write that into pseduocode?

	String doubleString = JOptionPane.showInputDialog (null, "Enter the Fahrenheit degree", "Converting Fahrenheit", JOptionPane.QUESTION_MESSAGE);
	double doubleValue =Double.parseDouble(doubleString);

	double cel = (5.0 / 9) * doubleValue -32;

  • 0
  liykh001 said:
^

funny as pseudo means not real :)

sorry I dont know any websites or anything that tell you how to write pseduo code.

generally you dont need one. just write the program logic

method that does something

doSomething( aNumber)

{

? ? while number is less than 5 {

? ? ?  finalNumber = aNumber + 100

? ? ?  aNumber = aNumber - 1

?  }

?  return finalNumber

}?

}

there is no real hard and fast rules to follow when writing pseudo code except that it should be readable. for example using "for (int i =0; i < 10; i++)" is not really readable.

you would write while (iterator less than 10) ...etc but really anything can be acceptable in pseduo

well that is my 2 cents on it.

586806996[/snapback]


:o oh so there is no actual answer for it?

  • 0

^

thats right, there are more degrees of pseudoness :)

fahrenheitDegrees = getFahrenheitDegreesFromUser();

degrees = (5.0 / 9) * fahrenheitDegrees -32;

or

degrees = (5 divided by 9) times by (fahrenheitDegrees minus 32);

  • 0

Well you phrased your question badly.

You don't write peudocode "for java". The idea of pseudo code is it is of a high enough language level for it to be developed into any programming language.

The idea is as follows:

Begin with a definition of your problem in readable English - e.g "Search an array for an object, and return its position in the array"

Then break that down into pseudo code - e.g

mySearch ( objectType[][] array, object )

FOR each item in the array

IF array[iterator] = object

RETURN true

END IF

END FOR

RETURN false

Then you create your java code from the pseudo code. Most people new to the idea will prefer to code the java first - that is ok for simple problems, but start doing anything complex and you'll need to write the pseudo code first.

P.S the board software will probably remove my spacing/indentation in the pseudo code but it was laid out nicely :)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.