Results 1 to 11 of 11
  1. #1
    kurtashug is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Need help with my homework?

    So I'm new to Java and don't know much about it at all. I have this homework project that I'm having a hard time with. I've been working on it for a few weeks and still struggling to the solutions.
    Instructions-
    Description : This program figures out the character type when the user inputs a single
    character. You will ask the user to input a single character. You will tell the user
    whether that character is an uppercase letter (A-Z), a lowercase letter (a-z), a digit, or
    special character.

    I'm supposed to determine a character type without using char functions..
    Here's is the instructions list.
    https://my.rsu.edu/ICS/icsfs/Program...4-3476b15f009b

    1.I'm using intellij IDEA
    2. I'm having problems with words print and printf, it says "cannot resolve symbol". I've already tried invalidating cache and restarting intellij and setting sdk to jdk but that didn't help.
    3. I'm only needing help with problems 6-8.
    4. I did question 6 but it showed too many errors.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Need help with my homework?

    What specific java programming questions do you have? Please post them here, not as links to other sites.

    Post any code here in code tags along with the full text of any error messages.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    kurtashug is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Need help with my homework?

    8. Use nested if-else statements to determine the character type, and do NOT use
    the char methods like isLetter or isDigit. Remember that you MUST use
    SINGLE quotes for char (double quotes mean String). I require you to format
    nested if statements nice and neat like (b) in Figure 3.3 (p. 82), NOT like
    (a) where it is strung across the page with a bunch of indentions. It is best to
    always use braces around the body inside the if-else statements to prevent
    accidental problems and to allow for easy addition of more lines later. Remember
    that char is really a type of integer in UNICODE (of which the first 128 characters
    match the old ASCII code system), so you can compare the char variable to
    another char like this:
    if (myChar >= 'a' && myChar <= 'z') // see if myChar is lowercase
    {
    // do stuff
    }
    else if ( )
    {
    // do other stuff
    }


    I have to determine a character type but I can't use the char functions.
    I'm stuck on problem 8. This is what I have so far.

    Need help with my homework?-capture.png

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Need help with my homework?

    You have messed up your curly braces. See the line below public static void main: it has a closing curly brace. That means the method is effectively empty, but worse, the statements after that are floating in mid air. Remove the closing curly brace after main and start balancing out the curly braces.

    Pro tip: NEVER EVER write if-statements without curly braces. Even though you can, doesn't mean you should. That will bite you in the behind sooner or later. So your if (aChar...) needs an opening curly brace.

    Pro tip #2: if you make a small change and suddenly you get a bazillion errors, count the parenthesis, brackets, braces first. Chances are that the structure of the file is messed up and the compiler will complain about everything.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Need help with my homework?

    You should post the error that the IDE is giving you, but anyway, in this case you have a mismatch with your brackets.
    The code you have there is not in the main method for starters (which is where I expect it should be).

    You also haven't opened any brackets for the if statement, just closed them.

    So first off, place your code inside the main method. That is, inside the brackets for the main method.

    By the way, you should post code here (in code tags) and not images.
    We can't copy and paste from an image.
    Luckily this one is a simpler issue.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    kurtashug is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Need help with my homework?

    I forgot to fix the curly braces, thanks for reminding me! My professor said I can use compareTo instead of string. I'm just really lost how do I go about this?

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Need help with my homework?

    use compareTo instead of string
    That does not make sense. compareTo is a method and String is a class. One can not be replaced with the other.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Need help with my homework?

    What does your "fixed" code look like now?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    kurtashug is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Need help with my homework?

    Need help with my homework?-capture.png

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Need help with my homework?

    Please post text not images. Make sure to include the full text of the error message.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Need help with my homework?

    That if statement is incorrect.
    It's not valid syntax.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Help on Homework
    By Messi5454 in forum Eclipse
    Replies: 28
    Last Post: 09-14-2013, 06:28 AM
  2. Need homework help
    By psx2514 in forum New To Java
    Replies: 5
    Last Post: 10-18-2012, 08:18 AM
  3. Homework help
    By noobster in forum New To Java
    Replies: 13
    Last Post: 10-31-2010, 09:02 PM
  4. Please Help with Homework
    By theuser in forum Advanced Java
    Replies: 2
    Last Post: 07-30-2009, 03:37 PM
  5. help with homework
    By pinkdiamondgail in forum Advanced Java
    Replies: 7
    Last Post: 04-07-2009, 01:34 AM

Posting Permissions

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