Results 1 to 3 of 3
  1. #1
    Matrice is offline Member
    Join Date
    Jul 2014
    Rep Power

    Default Scanner Grade confusion

    Hey all, it's been 6 days since I've started learning Java.
    I have decided to write a code all on my own today. Now, I have something that looks like it should do what I want it do to, but it doesn't. I want it to scan and correctly give the correct output depending on the user's input of a grade score (without the % sign). It seems that whatever I've done, has allowed it to give the 90% A grade no matter what score you input. I am still learning, but I think I am improving. Anyone want to teach me or guide me on this quest to learn?
    Attached Thumbnails Attached Thumbnails Scanner Grade confusion-screen-shot-2014-07-29-1.07.49-pm.png  

  2. #2
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Rep Power

    Default Re: Scanner Grade confusion

    Variable A has the value 90, so if 90 < 100 print A.

    You need another variable to store the input number and check the value against the different grades; .nextLong() returns a value, but you do not use it.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Scanner Grade confusion

    Every valid number is less than (or equal to) 100, so the first test always succeeds. For those half open intervals you have to start checking 'from the bottom', i.e. first check for an F, next for a D etc.

    kind regards,

    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. Java Grade 11 Beginner Help
    By dharav in forum New To Java
    Replies: 3
    Last Post: 12-18-2011, 06:01 PM
  2. Grade Book class, please help
    By star12345645 in forum New To Java
    Replies: 5
    Last Post: 12-11-2011, 03:46 AM
  3. Grade my questions, lol
    By syntrax in forum New To Java
    Replies: 4
    Last Post: 12-16-2009, 07:03 AM
  4. Help with JAVA (Grade Book)
    By Sara_21 in forum New To Java
    Replies: 3
    Last Post: 11-30-2009, 03:45 PM

Tags for this Thread

Posting Permissions

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