Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement