• Lenguaje

    Java usando Scanner

  • Descripción

    Evalúa la función:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Scanner;

public class FuncionX21X23X {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double x, y;
        System.out.print("Ingresa el valor de x: ");
        x = in.nextDouble();
        in.nextLine();
        y=0;
        if(x<-3)
            y=x*x-1;
        if(x>=-1&&x<8)
            y=x-2;
        if(x>=8)
            y=3.0-x;
        System.out.println("Valor de y: " + y);
    }

}