4 Replies - 5004 Views - Last Post: 14 April 2009 - 07:55 PM Rate Topic: -----

#1 Beginner2009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-April 09

pseudo code in java code

Posted 14 April 2009 - 06:40 AM

Hey how are you guys doing?

im trying to convert this snipet of of pseudo code in java code.

String operand = ""
get char c from current position in string (pos)
if c isn't (, ), +,-,*,/, or ^ then check if c is a letter
if c is a letter, operand+=c
  increment current position
  get char c from current position in string
  while c is a letter or a digit
	operand+=c
	increment current position
	get char c from current position in string
  end while
operand now contains the characters which make up its name


here what i got so far

 //method to check multi-variable characters
public String getMultiVariables(char c){  
	String operand = "";
	int pos=0;
	if(c != '*' || c!='/'||c!='+' ||c!='-'||c!='('||c!=')'||c!='^')
	 if(Character.isLetter(c))	  
		operand +=c;
	   pos++;
	
	while(Character.isLetterOrDigit(c))
	{	  
		operand +=c;
		pos++;
	  }
		  
	return "unknown type";
} 



not working thou close

any help at all will be good

thanx

This post has been edited by Beginner2009: 14 April 2009 - 11:22 AM


Is This A Good Question/Topic? 0
  • +

Replies To: pseudo code in java code

#2 Mikeyp926  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 205
  • Joined: 20-March 09

Re: pseudo code in java code

Posted 14 April 2009 - 09:30 AM

Here's a tip, actually write out some code and people will be much more likely to help you out :)

Anyway, I won't do the whole thing for you, but I can at least get you started in the right direction.

String operand =""
would be
String operand = "";


...that was a pretty easy translation, lol.

Most of the lines of this pseudo code pretty much tell you exactly what to do. If it says "while", then that is a hint to use a while loop and pretty the stated condition in the parenthesis. when it refers to "get char" that means you'll most likely want to use a string function to get the character at a specific index of a string.

Hope this helps! Put some effort into this and show us what you have done, then we will be more than happy to help correct anything or answer any questions.
-Michael
Was This Post Helpful? 0
  • +
  • -

#3 markhazlett9  Icon User is offline

  • Coding is a lifestyle
  • member icon

Reputation: 60
  • View blog
  • Posts: 1,666
  • Joined: 12-July 08

Re: pseudo code in java code

Posted 14 April 2009 - 09:39 AM

I disagree with the previous statement. PseudoCode has it's place and if you're doing pseudocode then stay away from actual code, it will just screw you up in the end. However, since you have the pseudocode already, and no java code was posted we will need to see some code before helping you out. DIC has a policy in which we like to see a good faith effort on your part before we do any work on our end. Please edit your post and post your code between the code tags like this...

:code:


Cheers
Was This Post Helpful? 0
  • +
  • -

#4 jahmassive  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-November 06

Re: pseudo code in java code

Posted 14 April 2009 - 10:42 AM

View PostMikeyp926, on 14 Apr, 2009 - 08:30 AM, said:

Here's a tip, actually write out some code and people will be much more likely to help you out :)

Anyway, I won't do the whole thing for you, but I can at least get you started in the right direction.

String operand =""
would be
String operand = "";


...that was a pretty easy translation, lol.

Most of the lines of this pseudo code pretty much tell you exactly what to do. If it says "while", then that is a hint to use a while loop and pretty the stated condition in the parenthesis. when it refers to "get char" that means you'll most likely want to use a string function to get the character at a specific index of a string.

Hope this helps! Put some effort into this and show us what you have done, then we will be more than happy to help correct anything or answer any questions.
-Michael

Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8316
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: pseudo code in java code

Posted 14 April 2009 - 07:55 PM

if(c != '*' || c!='/'||c!='+' ||c!='-'||c!='('||c!=')'||c!='^')
	 if(Character.isLetter(c))	  



So if C is not * or / or + or - or .....
check if it is a letter

why don't you just check if is a letter ? If it is a letter if wont be * / + - .....

Or there is something I missing ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1