Question: Correct and re-compile the program to disallow a vertical line (denominator = 0). When the denominiator is 0, output an error message. import java.util.Scanner; public

Correct and re-compile the program to disallow a vertical line (denominator = 0). When the denominiator is 0, output an error message.

import java.util.Scanner; public class Lab { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Input x coordinate of the first point: "); double xcoord1 = in.nextDouble(); System.out.print("Input y coordinate of the first point: "); double ycoord1 = in.nextDouble(); System.out.print("Input x coordinate of the second point: "); double xcoord2 = in.nextDouble(); System.out.print("Input y coordinate of the second point: "); double ycoord2 = in.nextDouble(); double slope = (ycoord2 - ycoord1) / (xcoord2 - xcoord1); System.out.println("The slope of the line is " + slope); } // end main method } // end class Lab

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!