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

Rounded Distance Note

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Create a distance helper that uses the Java Math library to report the exact and rounded distance between two points.

Input Format

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

  1. x1
  2. y1
  3. x2
  4. y2

Output Format

Print the exact report in this order:

  1. Distance
  2. Rounded

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
Distance: 5.00
Rounded: 5
Input: x1 = 0, y1 = 0, x2 = 3, y2 = 4.
Key calculation(s): distance = Math.hypot(3 - 0, 4 - 0) | rounded = Math.round(distance) | "Distance: " + String.format("%.2f", distance) = "Distance: 5.00".
Output:
Distance: 5.00
Rounded: 5
Sample #2
Public sample
1
2
4
6
Distance: 5.00
Rounded: 5
Input: x1 = 1, y1 = 2, x2 = 4, y2 = 6.
Key calculation(s): distance = Math.hypot(4 - 1, 6 - 2) | rounded = Math.round(distance) | "Distance: " + String.format("%.2f", distance) = "Distance: 5.00".
Output:
Distance: 5.00
Rounded: 5

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