Advertisement
Guest User

Untitled

a guest
May 17th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. public class findIntercepts {
  2.     //Finds X and Y intercepts for a line
  3.     public static void main (String args[]){
  4.         //input: Ax + By = C
  5.         double A =5;
  6.         double B =5;
  7.         double C =5;
  8.         System.out.println("X intercept: ("+findXIntercept(A,C)+ ",0)");
  9.         System.out.println("Y intercept: (0,"+findYIntercept(B,C)+")");
  10.     }
  11.     public static Object findXIntercept(double A, double C){
  12.         if (A==0){
  13.             return null;
  14.         }
  15.         else {
  16.             return C/A;
  17.         }
  18.     }
  19.     public static Object findYIntercept(double B, double C){
  20.         if (B==0){
  21.             return null;
  22.         }
  23.         else{
  24.             return C/B;
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement