Metric Converter
Програмата ми гърми на 78% и не мога да разбера, защо?
import java.text.DecimalFormat; import java.util.Scanner; public class ConvertMetric { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); DecimalFormat decimalFormat = new DecimalFormat("#.########"); double value = Double.parseDouble(scanner.nextLine()); String input = scanner.nextLine(); String output = scanner.nextLine(); double m = 1.0; double mm = 1000; double cm = 100; double mi = 0.000621371192; double in = 39.3700787; double km = 0.001; double ft = 3.2808399; double yd = 1.0936133; switch (input){ case "m": value = value / m; break; case "mm": value = value / mm; break; case "cm": value = value / cm; break; case "mi": value = value / mi; break; case "in": value = value / in; break; case "km": value = value / km; break; case "ft": value = value / ft; case "yd": value = value / yd; break; default: break; } switch (output){ case "m": value = value * m; break; case "mm": value = value * mm; break; case "cm": value = value * cm; break; case "mi": value = value * mi; break; case "in": value = value * in; break; case "km": value = value * km; break; case "ft": value = value * ft; case "yd": value = value * yd; break; default: break; } System.out.println(decimalFormat.format(value)); } }
Благодаря !