Pig Latin problem.

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 8827 Views - Last Post: 15 July 2012 - 12:38 AM Rate Topic: -----

#16 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Pig Latin problem.

Posted 15 July 2012 - 12:28 AM

Something like that. Only you need to assign the value that returns to a variable.

See, I told you you knew it.
Was This Post Helpful? 0
  • +
  • -

#17 theNoob   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 66
  • Joined: 14-July 12

Re: Pig Latin problem.

Posted 15 July 2012 - 12:31 AM

View Postjon.kiparsky, on 15 July 2012 - 12:28 AM, said:

Something like that. Only you need to assign the value that returns to a variable.

See, I told you you knew it.


Please pardon my slang... but LOL.

Thanks for the help again. Also I think I may have figured out another way. I get one logical error which shows my newLname outputs incorrectly

		String fname = "john";
		String lname = "smith";
		
		fname.toLowerCase();
		lname.toLowerCase();
		
		String newFname = fname.substring(1) + fname.charAt(0) + "ay";
		String newLname = lname.substring(1) + lname.charAt(0) + "ay";
		
		String updateFname = newFname.substring(0,1);
		String updateLname = newLname.substring(0,1);
		
		updateFname = updateFname.toUpperCase();
		updateLname = updateLname.toUpperCase();
		
		newFname = updateFname + newFname.substring(1);
		newLname = updateLname = newLname.substring(1);
		
		System.out.println("Your Pig Latin name is: ");
		System.out.println(newFname + " " + newLname);




Was This Post Helpful? 1
  • +
  • -

#18 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Pig Latin problem.

Posted 15 July 2012 - 12:35 AM

Yep, that looks okay from here.

Could quibble, but I'm sure there are some who will do it for me. For now, as long as it passes your test cases (you do test your code, I hope?) it's probably okay.
Was This Post Helpful? 0
  • +
  • -

#19 theNoob   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 66
  • Joined: 14-July 12

Re: Pig Latin problem.

Posted 15 July 2012 - 12:38 AM

View Postjon.kiparsky, on 15 July 2012 - 12:35 AM, said:

Yep, that looks okay from here.

Could quibble, but I'm sure there are some who will do it for me. For now, as long as it passes your test cases (you do test your code, I hope?) it's probably okay.


One of my friend helped me figure out what the error was. I fixed it and now it works fine.

//newLname = updateLname = newLname.substring(1);
// the line above is incorrect and it should be

newLname = updateLname + newLname.substring(1);



Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2