Results 1 to 10 of 10
Thread: Problem that I can't solve...
 11162011, 12:16 AM #1Member
 Join Date
 Nov 2011
 Posts
 12
 Rep Power
 0
Problem that I can't solve...
Hi guys, I want input angle a,b,c that is in the range of 0180. Otherwise, it would not make a quadrilateral shape. I have made an attempt using an 'if' statement, but it doesn't do what I want it to.
note that Min = 0 Max=180.
Here's a piece of my code:
System.out.println("Enter Angle A = ");
int AA = input.nextInt();
if ((AA < MIN) && (AA > MAX)); {
System.out.println("This is not in the range.");
}
Say i input 999 for angle A, it inputs it and shows a message saying "This is not in the range."  YES!
However, I want another "int AA = input.nextInt();" to input again so the user can input a number again and replaces the previous number. I have tried this and it doesn't work and get errors. :(
thanks.Last edited by Wing.Sham; 11162011 at 12:18 AM.
 11162011, 12:26 AM #2
Re: Problem that I can't solve...
I suggest you place a forloop around this that will keep running until the user enters a value that is within the range. Then write the else coding for what you want it to do if the angle is within the range.
 11162011, 12:28 AM #3Member
 Join Date
 Nov 2011
 Posts
 12
 Rep Power
 0
 11162011, 12:33 AM #4
Re: Problem that I can't solve...
I can't see why not, but either way should work
 11162011, 12:35 AM #5
Re: Problem that I can't solve...
Yes a while loop would be best. Also how can a value be less than 0 AND greater than 180?
 11162011, 12:37 AM #6Member
 Join Date
 Nov 2011
 Posts
 12
 Rep Power
 0
Re: Problem that I can't solve...
 11162011, 12:40 AM #7Member
 Join Date
 Nov 2011
 Posts
 12
 Rep Power
 0
Re: Problem that I can't solve...
The thing is... I have not started using loops in java. We start that tomorrow. I'll give it a try and see if it works. Would I have to use ++ to increment??
 11162011, 01:12 AM #8
Re: Problem that I can't solve...
You can put a nice big IF around the while statement
 11162011, 01:21 AM #9Member
 Join Date
 Nov 2011
 Posts
 12
 Rep Power
 0
 11162011, 01:31 AM #10
Similar Threads

Solve JVM Problem
By pedroffbarbosa in forum Advanced JavaReplies: 8Last Post: 11282011, 11:35 PM 
Need help to solve my problem
By Copro in forum New To JavaReplies: 4Last Post: 08212009, 04:26 AM 
Help me to solve problem
By mansoorhacker in forum Forum GuidesReplies: 8Last Post: 01242009, 06:29 PM 
Solve my Problem
By kyo in forum New To JavaReplies: 1Last Post: 12162008, 02:22 PM 
Help me to solve problem
By mansoorhacker in forum New To JavaReplies: 3Last Post: 11132008, 08:15 AM
Bookmarks