012-002-003
Static Method: Unit Conversion
Medium
Problem Description
Static Method: Unit Conversion
Learning Objective: Understand the characteristics of static methods
Create a Converter class with a static method to convert kilometers to miles.
Input
Line 1: Kilometers (decimal)
Output
[km] km = [miles] miles
```java
* 1km = 0.621371 miles (display with 2 decimal places)
## Example
Input:
```java
10.0
```java
Output:
```java
10.0 km = 6.21 miles
Test Cases
※ Output examples follow programming industry standards
Input:
10.0
Expected Output:
10.0 km =6.21 miles
Input:
1.0
Expected Output:
1.0 km =0.62 miles
Input:
0.0
Expected Output:
0.0 km =0.00 miles
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 9 free executions remaining
