Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Java and 0

  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java and 0

    I wrote a programm and now i am having truble with the number 0....

    What the programm does:
    You enter two names and their test scores, then the programm comares their highscores and says who has the highest...

    However when i put in 0 for one of the scores it thinks that 0 is higher then 100, why?

    thanks...

    the zip: http://free.networkthai.net/x/someone/Student.zip

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Are you converting the numbers to integers or floats before you compare them? If not then you are likely comparing the ascii values of the characters 0 and 100 and not actually the value 0 and 100.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes they are int... So what is wrong? did u look at my script?

    thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •