Over a million developers have joined DZone.

Find X, Y Intercepts Of A Line

DZone's Guide to

Find X, Y Intercepts Of A Line

Free Resource
//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;
			return C/B;

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}