Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I have this assignment question ; I have problem in the third part ( The line intersect ), I couldn't figure it out and

Hello

I have this assignment question ;

image text in transcribed

I have problem in the third part ( The line intersect ), I couldn't figure it out

and I want to make sure that other solutions are ok

###

ublic class homework2 {

public static void main(String[] args) {

Scanner b = new Scanner(System.in);

System.out.println("Enter your slope_1 : ");

double slope_1;

slope_1=b.nextDouble();

System.out.println("Enter your Y_Intersects_1 : ");

double Y_Intersects_1;

Y_Intersects_1=b.nextDouble();

System.out.println("Enter your slope_2 : ");

double slope_2;

slope_2=b.nextDouble();

System.out.println("Enter your Y_Intersects_2 : ");

double Y_Intersects_2;

Y_Intersects_2=b.nextDouble();

double x,y;

x = Y_Intersects_1-Y_Intersects_2 /slope_1-slope_2 ;

y= slope_1 + Y_Intersects_1;

if (Y_Intersects_1 - Y_Intersects_2 == 0) {

System.out.print("The line intersect at:");

System.out.print(x);

System.out.print(y);

}

else if

(Y_Intersects_1 - Y_Intersects_2

System.out.print("Overlap");

}

else if

(Y_Intersects_1-Y_Intersects_2 >= 0.01 ) {

System.out.print("NO intersect");

}

}

}

###

Thank you

Input (from console): Y intersects (type double) and slopes (type double) of two lines (with the order of slope1, yintersect1, slope2, yintersect2) on the Cartesian planeOutput (to console): "No intersect" if the lines do not have any intersect, "Overlap" if the lines overlap or are closer than 0.01 to eachother, and "The lines intersect at X = [double), Y = [double]", if the lines intersect. Example1: Input: slope1- 1, yIntersectl-1,slope2 -1. yIntersect2- 1.0001 Output: "Overlap" Example2: Input: slope1- 1, yIntersectl -2, slope2 1. yIntersect2 1 Output: "No intersect" Example3: Input: slope1- 2, yIntersect1 3, slope2- -0.5, yIntersect2 ourput: ''The lines intersect at X 1.6, Y = 6.2" 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions