This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dialog boxes and two users

 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok below is a code i have been trying to put together. I want there to be two seprate users that as dialog boxes pop up they enter their first name then last and then their age. Each user does that and then in the end i want to compare the ages and the last dialog box to say:

First Person: Smith, John (31)
Second Person: Doe, Mike (35)
Doe is older than Smith


So here is my code and i know i have serveral errors, can someone help me?

[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ September 09, 2004: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry about that. i didnt realize that would happen. thanks for the tip.

 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's really not too bad. The main problem is that you're assigning the value returned from showInputDialog() directly to age1 and age2, which are integers. You'll need separate String variables to hold the String values, and pass those values to parseInt() and assign the return values of parseInt() to the ageX variables.

Make sense?
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sort of...im a little lost? so i put the dialog boxes in string variables and ages in a different variable? sorry im a little a slow at this. im new so i dont really know what everything means i have to go and look it up.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic