用java实现英里与千米之间的转换(1英里为1.609千米)
package nameyu;public class Test { /** * @param args */ public static void main(String[] args) { int miles=1,kilometers=1; System.out.printf("%-5s%-5s%-6s%-5s%n","英里","千米","千米","英里"); double answermiles,answerkilometers; for(miles=1,kilometers=20;miles<=10&&kilometers<=65;miles++,kilometers=kilometers+5){ answerkilometers=miles*2.2; answermiles=kilometers*1.609; System.out.printf("%-5d%-5.2f%-6d%-5.2f%n",miles,answerkilometers,kilometers,answermiles); } } }
页:
[1]