import java.text.ChoiceFormat; public class ChoiceFormatApp { public static void main(String args[]) { double limits[] = { 0.0, 0.1, 0.3, 0.7 }; String labels[] = { "very low", "low", "moderate", "high" }; ChoiceFormat format = new ChoiceFormat(limits, labels); double r = Math.random(); System.out.println(format.format(r) + " (" + r + ")."); } } //high (0.755370803805559).