Results 1 to 12 of 12
  1. #1
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default What's wrong with my code

    Got my help. Thanks.
    Last edited by coding; 03-08-2011 at 05:39 AM.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    8

    Default

    Parse the String to an Integer (e.g. with Integer.parseInt) or read an int, not a String :D

  3. #3
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    How would I do that? 'm confused. It would help if you showed me.

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    11

    Default

    He gave you a link to the way to do it. You are comparing a string to an integer, and that is why you are getting an error. First you must convert the string to an integer. Try googling it and you won't have a hard time figuring it out.

  5. #5
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    Like this?
    int parseInt"(String grade,int grades);
    Still not helping. I'm getting errors.

  6. #6
    Ruuhkis is offline Member
    Join Date
    Feb 2011
    Posts
    19
    Rep Power
    0

    Default

    int number = Integer.parseInt(grade);
    like this bro

  7. #7
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    I tried this but it still didn't work.

    SimpleIO.prompt("Enter a number from 1-100");
    String grade = SimpleIO.readLine();
    Integer i = Integer.parseInt("grade");
    if (i > 100)

  8. #8
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    Quote Originally Posted by Ruuhkis View Post
    like this bro
    Thanks, let me try it.

  9. #9
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    Thanks that worked. I will now continue working on my code and post back if I have anymore problems.

  10. #10
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    Edited first post with new question.

  11. #11
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,807
    Rep Power
    10

    Default

    Quote Originally Posted by coding View Post
    Edited first post with new question.
    Don't do that. Just post your new question in a brand new reply.
    Java Code:
    if ( number < 0)
        i+=1; // only line of code in your if statement
    {  // completey separate block of code starts here
        System.out.println("You must enter an integer between 0-100");
        SimpleIO.prompt("Enter a number 0-100");
    } //ends here

  12. #12
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    Thanks. If I fix that will that fix the double lines being sent back instead of one at a time?

    Also is it correct with i being >= 3 it ends?


    Edit:

    I split up the statement with brackets and it didn't change.

    Also I want it to ask you a second time what your number is until the limit is 3 or higher. But after entering your number once it ends.
    Last edited by coding; 03-01-2011 at 03:00 AM.

Similar Threads

  1. Help with fixing timer
    By acash229 in forum New To Java
    Replies: 1
    Last Post: 09-13-2010, 06:27 AM
  2. THIS PROGRAM IS DRIVING ME CRAZY!!! help fixing it
    By syntrax in forum New To Java
    Replies: 2
    Last Post: 12-18-2009, 05:27 AM
  3. [SOLVED] I need help fixing an error
    By leonardjr in forum New To Java
    Replies: 8
    Last Post: 02-21-2009, 09:33 PM
  4. help with fixing my assignment.please...error
    By Jin-enigma-PL in forum New To Java
    Replies: 4
    Last Post: 02-05-2009, 01:12 AM
  5. Exception Error need help fixing
    By skinnybones in forum New To Java
    Replies: 2
    Last Post: 12-03-2007, 08:14 PM

Posting Permissions

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