Results 1 to 4 of 4
Thread: Re-enter information question
- 11-06-2012, 06:55 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
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?
-
Re: Re-enter information question
Please post your question only once on the forum. I've closed your duplicate post.
-
Re: Re-enter information question
Regarding your question, you need to use a loop for this. Look up using a while loop since that's what you'll need.
- 11-06-2012, 07:32 PM #4
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Re-enter information question
By viperkevin in forum Forum GuidesReplies: 1Last Post: 11-06-2012, 07:20 PM -
PC information question
By roofninja in forum New To JavaReplies: 7Last Post: 09-11-2012, 03:56 PM -
signer information does not match signer information of other classes
By swyatt in forum New To JavaReplies: 5Last Post: 04-27-2011, 09:14 PM -
How Enter key act like TAB?
By mine0926 in forum New To JavaReplies: 2Last Post: 06-03-2010, 06:44 AM -
enter key in swt
By ashin in forum SWT / JFaceReplies: 0Last Post: 07-17-2009, 09:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks