|
-
August 20th, 2009, 08:21 AM
#1
Basic java problem
Hi i need some help to implement the limit of characters one can type. It should show an error msg that the user cannot input more than 2 characters in x coordinate and y coordinate. How should i do that?
import java.util.Scanner;
public class P1
{
public static void main(String[]args)
{
int xaxis,yaxis;
Scanner sc= new Scanner(System.in);
System.out.println("Enter the X Coordinates:");
xaxis = sc.nextInt();
System.out.println("Enter the Y Coordinates:");
yaxis = sc.nextInt();
if(xaxis >=0 && yaxis >=0)
System.out.println("Q1");
else if(xaxis < 0 && yaxis >=0)
System.out.println("Q2");
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|