Previous Next
0 / 15
Module DEMO-33-71DEMO-OOP-33

Route Distance Analyzer

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Create a helper class that analyzes a two-leg route using the Java Math library.

Input Format

Input is given as whitespace-separated tokens in this order:

  1. x1
  2. y1
  3. x2
  4. y2
  5. x3
  6. y3

Output Format

Print the exact report in this order:

  1. Leg One
  2. Leg Two
  3. Total

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
0
0
3
4
6
8
Leg One: 5.00
Leg Two: 5.00
Total: 10.00
Input: x1 = 0, y1 = 0, x2 = 3, y2 = 4, x3 = 6, y3 = 8.
Key calculation(s): legOne = Math.hypot(3 - 0, 4 - 0) | legTwo = Math.hypot(6 - 3, 8 - 4) | "Leg One: " + String.format("%.2f", legOne) = "Leg One: 5.00".
Output:
Leg One: 5.00
Leg Two: 5.00
Total: 10.00
Sample #2
Public sample
1
1
4
5
4
9
Leg One: 5.00
Leg Two: 4.00
Total: 9.00
Input: x1 = 1, y1 = 1, x2 = 4, y2 = 5, x3 = 4, y3 = 9.
Key calculation(s): legOne = Math.hypot(4 - 1, 5 - 1) | legTwo = Math.hypot(4 - 4, 9 - 5) | "Leg One: " + String.format("%.2f", legOne) = "Leg One: 5.00".
Output:
Leg One: 5.00
Leg Two: 4.00
Total: 9.00

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings