Java基础-计算y的值-程序没有结果??

package test;
//有一函数,y与x有如下关系:
//x>=3        y = 2 * x + 1;
//-1<x<3    y = 2 * x;
//x<=-1        y = 2 * x - 1; 
//编程,让键盘录入x的值,计算出y的并输出。
import java.util.Scanner;

public class p3 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入");
        int x=sc.nextInt();
        int y=0;    
        if(x>=3) {
            y=2*x+1;
        }else {
            if(-1<x&&x<3){
                y=2*x;
            }else {
                if(x<=-1) {
                    y=2*x-1;
                    System.out.println(y);
                }
            }
        }
sc.close();
    }

}
 

system.out.print移到y=0那一级

Scanner sc=new Scanner(System.in);
        System.out.println("请输入");
        int x=sc.nextInt();
        int y=0;
        if(x>=3) {
            y=2*x+1;
        }else {
            if(x>-1&&x<3){
                y=2*x;
            }else {
                if(x<=-1) {
                    y=2*x-1;

                }
            }
        }
        System.out.println(y);
        sc.close();

你把输出y放出来,还有你的 if(-1<x&&x<3)改一下