从键盘输入x,根据以下情形求y的值并输出: 
y=0;   当x≤0时,
y=2x+1;  当0<x<5时
y=X2-1;  当x≥5时

解决方案 »

  1.   

    http://wenwen.soso.com/z/q164712600.htm
      

  2.   

    import java.io.*;public static void main(String[]args) throws IOException{   String buf = "";
       int y = 0;
       int x = 0;   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)));
       
       System.out.println("请输入任意一个整数:");   buf = reader.readLine();
       x = Integer.parseInt(buf);   if(x <= 0){
         
          y = 0;
       }
       else if(x > 0 && x < 5){
         y = 2*x+1;
       }
       else if(x >= 5){
          y = 2*x - 1;
       }else{
           System.our.println("Something wrong happend.");
           System.exit(1);
       }   System.our.println("y = " + y);
    }