第1个回答 2011-03-05
public class Caculate{
public static double getY(double x){
if(x<1){
return x;
}
if(x>=1&&x<10){
return 3*x-2;
}
if(x>=10){
return 4*x;
}
}
//测试
public static void main(String args[]){
Scanner cs = new Scanner(System.in);
String aa = cs.next(); //接受键盘输入的数据
double x = Double.parseDouble(aa );//将字符穿转化为double类型
double y = getY(x);
System.out.println(y);
}
}