标签:os ar java 数据 ad new as 字符串 class
import java.util.Scanner;
public class addd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//定义数据类型
double L, IL = 0;
System.out.print("请输入尺寸:");
//数值的录入
L = sc.nextDouble();
System.out.print("请输入单位:");
//字符串的录入
String dw = sc.next();
//判断关键字符是“cm”
if (dw.equals("cm") ){
IL = L / 2.54;
System.out.printf("%.1f厘米=%.1f英寸",L , IL);
}
//判断关键字符是“inch”
else if(dw.equals("inch") ){
IL = L * 2.54;
System.out.printf("%.1f英寸=%.1f厘米",L , IL);
}
sc.close();
}
}
标签:os ar java 数据 ad new as 字符串 class
原文地址:http://www.cnblogs.com/JamseWilson/p/4025378.html