← Unit 3 · all exercises
Saved in this browser only

A value that never changes

Write a Converter class with a static constant MILES_PER_KM equal to 0.621371, and a static method toMiles that multiplies kilometres by it.

class Converter { static final double MILES_PER_KM; static double toMiles(double km); }

Converter.java
Loading editor…
Results

Examples

  • Converter.toMiles(1) → 0.621371
  • Converter.toMiles(0) → 0

There are also 3 hidden tests you can't see. Solve the problem, not the examples.