Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

comparison  RSS feed

 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
heres a new code: how do i fix the end to say the following:

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

and have it where three different things can happen i.e. doe older that smith, smith older than doe, or the same age.

 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code works perfectly, once you remove all the silly mistakes.

I feel like you can figure them out on your own. but a few hints:

if(boolean)
do stuff;

is an if statement. you have

if(boolean) =
do stuff;

that equals sign doesn't make sense

next: end every statement with a ;. you may not end a string with +.

Variable names must be unique. you can't have both a string and an int with user1age.

what is 'choice'? if I'm the computer, how do I recognize 'choice'?

final note:
put some time into debugging your code before you ask someone else to fix it.
[ September 11, 2004: Message edited by: Joseph George ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like to program in tiny little baby steps. I write one line of code and then check to see if it compiles. (I use a fancy IDE that checks syntax continuously as I type.) This way, whenever I do have a compiler error, I have a pretty good idea of exactly where it is, and it's usually pretty easy to recognize the mistake quickly.

I've run into quite a few very new programmers that had the habit of writing dozens of lines of code before seeing what the compiler had to say about what things. These folks also seemed to have problems figuring out fixing the dizzying web of errors they'd often face.
[ September 11, 2004: Message edited by: Dirk Schreckmann ]
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
appologies for a perhaps over brusque response.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!