VaultNetwork.net Vault Network Boards
Author Topic: Java programming help. [Locked]
Albdestroyer  2 stars
Posts: 484
Registered: 2006-9-24 21:06:19
Very new to java, and I'm using jOptionPane right now.

I'm supposed to prompt for the users first and last name, and output just the first name. No f***ing clue how to do that.

I know how to get it to output both in a dialog box.

Any help will be appreciated.

that's me code so far.

public class Program313
{
public static void main( String [ ] args )
{
String name = JOptionPane.showInputDialog( null,
"Please enter your first and last names";

JOptionPane.showMessageDialog( null, "Hello, " + name);


}
}
Immortal_Haze  2 stars
Posts: 498
Registered: 2002-1-31 17:54:09
link

The brute force, easy way.

 

-----signature-----

"Those who have long enjoyed such privileges as we
enjoy forget in time that men have died to win them." FDR
Poit-Narf  1 star
Title: Cleric of Juan
Posts: 186
Registered: 2004-7-11 11:45:47
Read this.

 

-----signature-----
"I think so, Brain, but there's still a bug stuck in here from last time."
Rift: Deepstrike/Guardian
Poit (Mage), Point (Rogue), Popit (Cleric), Poiyt (Warrior)
http://immortal-guild.com/
"ou're so heterophobic" -Lyli
Albdestroyer  2 stars
Posts: 484
Registered: 2006-9-24 21:06:19
I feel like those two things are a bit more advanced than where I am.

these are the directions.

Write a program that reads a full name from a dialogbox; you should expect the first and last name to be separated by a space. Retrieve the first name and output it.
gatzby  1 star
Title: Insanity Personified
Posts: 86
Registered: 2001-7-26 17:49:19
http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input

 

-----signature-----
Radio Shack TRS 80 | 640k | 5.25 Drive INTEGRATED!
A stretched thread = A useless thread
Immortal_Haze  2 stars
Posts: 498
Registered: 2002-1-31 17:54:09
gatzby posted:

http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input



He's already done that, he's asking how to parse a string using a space as a delimiter.

Alb, here's a code example of what Poit referenced using split: link

 

-----signature-----

"Those who have long enjoyed such privileges as we
enjoy forget in time that men have died to win them." FDR
Albdestroyer  2 stars
Posts: 484
Registered: 2006-9-24 21:06:19
Immortal_Haze posted:

gatzby posted:

http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input



He's already done that, he's asking how to parse a string using a space as a delimiter.

Alb, here's a code example of what Poit referenced using split: link



That helps me, thanks. I guess I needed to see it laid out in a code example, heh.
gatzby  1 star
Title: Insanity Personified
Posts: 86
Registered: 2001-7-26 17:49:19
Teaches me to post while not paying attention, lol.

 

-----signature-----
Radio Shack TRS 80 | 640k | 5.25 Drive INTEGRATED!
A stretched thread = A useless thread
Immortal_Haze  2 stars
Posts: 498
Registered: 2002-1-31 17:54:09
Albdestroyer posted:

That helps me, thanks. I guess I needed to see it laid out in a code example, heh.



Don't sweat it, you'll find that a lot as you get used to syntax and whatnot. The Java documentation is a fantastic resource and very well done, but often you don't quite know the right question to ask when you're starting out.

 

-----signature-----

"Those who have long enjoyed such privileges as we
enjoy forget in time that men have died to win them." FDR

VaultNetwork.net is an independently operated community forum and is not affiliated with, endorsed by, or technically based on IGN, GameSpy, FilePlanet, GameStats, or the former IGN/GameSpy Vault Network.
References to VaultNetwork.net mean this site/domain. VNBoards-style presentation is a visual homage only. By using this site, you agree to the forum rules.