Amdocs Interview Question
Software EngineersTeam: Java
Country: United States
Interview Type: Written Test
{
import java.util.Scanner;
class Shape{
int shapeX=200;
int shapeY=300;
public void isBounded(int x,int y){
if(x<shapeX && y<shapeY){
System.out.println("Both points lie inside shape");
}else if(x>shapeX && y>shapeY){
System.out.println("Both points lie outside shape");
}else if(x==shapeX && y==shapeY){
System.out.println("Both points lie on the shape");
}
else{
if(x>=shapeX && y<shapeY){
System.out.println("Point x lies outside shape && point y lies inside shape");
}else if(x>=shapeX && y==shapeY){
System.out.println("Point x lies outside shape && point y lies on shape");
}else if(x<=shapeX && y>=shapeY){
System.out.println("Point x lies inside shape && point y lies outside shape");
}else if(x==shapeX && y>=shapeY){
System.out.println("Point x lies on shape && point y lies outside shape");
}
}
}
}
public class BoundaryConditions {
public static void main(String[] args) {
Shape shape=new Shape();
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int y=sc.nextInt();
shape.isBounded(x, y);
}
}
}
Is this code correct solution?
I would propose the following pseudo code:
Hope this make sense. I am looking forward for some more exciting solutions :)
- autoboli February 20, 2015