在Java中计算在范围内的表达式 并输出结果表达次方

      package net.lyt.month1;

import java.util.Scanner;

public class Java23 {
    public static void main(String[] args) {
        int x;
        Scanner sc = new Scanner(System.in);
        System.out.print("x = ");
        x = sc.nextInt();
        float y;
        if (x >= 1) {
            y = 3 * x * x - 1;
            System.out.println("y = "+y);
        } else if (-1 <= x & x < 1) {
            y = -2 * x + 5;
            System.out.println("y = "+y);
        } else if (x < -1) {
            y = 4 * x * x + 3;
            System.out.println("y = "+y);
        }
      }
      }  
上一篇:map函数式接口,代替if_else


下一篇:Cha_03 控制语句