Results 1 to 2 of 2
  1. #1
    viperkevin is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Question Re-enter information question

    Hi guys,

    I'm using BlueJ, doing a small project for College.
    The project involves getting the user to enter information, do some calculations inside Java and showing the results a number of ways.

    My problem is this:
    How do I code it so that incorrect information needs to be reentered?

    For example- If the user enters a grade of 110, it must be between 0-100 so how do I make it go back to reentering?
    (Awkward wording )

    Here's my current code:

    System.out.print("Critical Thinking grade: ");
    opGrade=sc.nextInt();
    if(opGrade<0 || opGrade >100)
    {
    System.out.println("Please reenter the number");
    System.out.println();
    System.out.print("Critical Thinking grade: ");
    stuNumber=sc.nextInt();
    }
    Using this way works, except if the wrong number is entered again, it just skips to the next question.

    Kelp?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. PC information question
    By roofninja in forum New To Java
    Replies: 7
    Last Post: 09-11-2012, 04:56 PM
  2. Replies: 5
    Last Post: 04-27-2011, 10:14 PM
  3. How Enter key act like TAB?
    By mine0926 in forum New To Java
    Replies: 2
    Last Post: 06-03-2010, 07:44 AM
  4. Enter
    By Arnold in forum New To Java
    Replies: 8
    Last Post: 10-18-2009, 10:17 AM
  5. enter key in swt
    By ashin in forum SWT / JFace
    Replies: 0
    Last Post: 07-17-2009, 10:42 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
  •