Results 1 to 13 of 13

Thread: HELP! Urgent.

  1. #1
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default HELP! Urgent.

    Hi guys, I get and error saying " 'else' without 'if " in this statement:

    if (angled >0 && 180<angled) {
    System.out.printf("\n angle D = %f",+ myQuad.angled());
    else
    System.out.printf("This does not make the total of 360 degrees");
    }

    Can anyone help me with this? I have to hand this in tomorrow.
    Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: HELP! Urgent.

    Check the placement of your curly brackets.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    javaTurtle is offline Member
    Join Date
    Nov 2011
    Location
    Arizona
    Posts
    10
    Rep Power
    0

    Default Re: HELP! Urgent.

    you else is embeded in the if statement
    if-else needs to be in this format
    if (1 == 1){
    //do something
    }
    else
    {
    //do nothing
    }

  4. #4
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: HELP! Urgent.

    Got that bit working. just a minute ago. thx guys

  5. #5
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: HELP! Urgent.

    but it won't find angle D when i input angle a,b,c..

  6. #6
    khehrap is offline Member
    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0

    Default Re: HELP! Urgent.

    Hi sorry for posting something irellevant, but just wanted to ask, i have just posted a post and says should be up after mod checks... how long does this take (sorry i am new to this)

    Thanks

  7. #7
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: HELP! Urgent.

    thanks. I'm sure it was something to do with the curly brackets

  8. #8
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: HELP! Urgent.

    Quote Originally Posted by khehrap View Post
    Hi sorry for posting something irellevant, but just wanted to ask, i have just posted a post and says should be up after mod checks... how long does this take (sorry i am new to this)

    Thanks
    I'm new to this too. You should get replies very soon.

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: HELP! Urgent.

    Quote Originally Posted by khehrap View Post
    Hi sorry for posting something irellevant, but just wanted to ask, i have just posted a post and says should be up after mod checks... how long does this take (sorry i am new to this)

    Thanks
    I just approved your thread so it should be visible to anyone now.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: HELP! Urgent.

    Quote Originally Posted by JosAH View Post
    Check the placement of your curly brackets.

    kind regards,

    Jos
    Thx. I get this error which is the same code i posted at the top. It says:

    angle D = Exception in thread "main" java.util.IllegalFormatConversionExceptio
    : f != java.lang.Integer
    at java.util.Formatter$FormatSpecifier.failConversion (Unknown Source)
    at java.util.Formatter$FormatSpecifier.printFloat(Unk nown Source)
    at java.util.Formatter$FormatSpecifier.print(Unknown Source)

    I changed the print method numerous times and still cannot get passed this.

    Do you know the exact problem to this??

  11. #11
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: HELP! Urgent.

    I changed the print method numerous times and still cannot get passed this.

    Do you know the exact problem to this?
    Check the + operation in the code you originally posted. And make sure it is the right format specifier for whatever argument you use in the code you are currently using. (%d for ints and %f for floating point arguments.)
    Last edited by pbrockway2; 11-15-2011 at 09:07 PM.

  12. #12
    Wing.Sham is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: HELP! Urgent.

    Yeah, I looked up on the internet and used %d and it worked. Thanks boss :)

  13. #13
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: HELP! Urgent.

    You're welcome.

    The API docs are too much to try and remember, but well worth bookmarking as a place to go to when haveing trouble getting printf to print the way you want: Formattable (Java Platform SE 6)

Similar Threads

  1. urgent help please
    By marksey07 in forum New To Java
    Replies: 4
    Last Post: 03-08-2011, 03:35 AM
  2. Urgent HELP!
    By Mp4Player in forum New To Java
    Replies: 2
    Last Post: 01-04-2011, 08:34 PM
  3. [URGENT]SHA Encryption System...need urgent helps
    By java_idiot in forum New To Java
    Replies: 6
    Last Post: 05-02-2010, 10:04 AM
  4. Please Help me urgent help please
    By ravjot28 in forum New To Java
    Replies: 2
    Last Post: 01-30-2010, 01:59 PM
  5. Urgent!!!
    By winnie99 in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 12-18-2009, 03:17 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
  •