DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Find X, Y Intercepts Of A Line
//Finds X, Y intercepts of a line
public class findIntercepts {
//Finds X and Y intercepts for a line
public static void main (String args[]){
//input: Ax + By = C
double A =5;
double B =5;
double C =5;
System.out.println("X intercept: ("+findXIntercept(A,C)+ ",0)");
System.out.println("Y intercept: (0,"+findYIntercept(B,C)+")");
}
public static Object findXIntercept(double A, double C){
if (A==0){
return null;
}
else {
return C/A;
}
}
public static Object findYIntercept(double B, double C){
if (B==0){
return null;
}
else{
return C/B;
}
}
}




