// // ... // Goal: mile <=> kile // import java.text.DecimalFormat; import java.util.Scanner; class ConvKM { public static void main(String[] args) { DecimalFormat f1 = new DecimalFormat("0.0"); // p.32 Scanner input = new Scanner(System.in); String anw; // "m" or "k" System.out.print("Read a letter (m/k): "); anw = input.next(); // debug //System.out.println("ANW = " + anw); if(anw.compareTo("m")==0) { System.out.print("m => k. Input the mile #: "); double tempM = input.nextDouble(); double kile = tempM * 1.609344; System.out.println("The kilemeter: " + f1.format(kile)); } else if (anw.compareTo("k")==0) { System.out.println("k => m"); } else System.out.println("Invalid input"); System.out.println("\n\nDone.\n\n"); } }