// using * saves typing import java.util.*; import java.io.*; public class Point2Line { public static void main(String[] args) { // in and out can be typed faster than input and output Scanner in = new Scanner(System.in); PrintStream out = System.out; // n is a constant but typing final takes type int n = in.nextInt(); // read the end of line in.nextLine(); for (int i = 0; i < n; i++) { // process input int x1 = in.nextInt(); int y1 = in.nextInt(); int A = in.nextInt(); int B = in.nextInt(); int C = in.nextInt(); // read the end of line in.nextLine(); // compute distance using the formula given in the question double distance = Math.abs((A * x1 + B * y1 + C) / Math.sqrt(A * A + B * B)); // print the distance (make sure that you match the output exactly) out.printf("Case %d: The distance is %.2f.%n", i + 1, distance); } } }