-
Lenguaje
Java usando Scanner
-
Descripción
Obtener el valor de Y de la ecuación: y = x² - 2x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.util.Scanner;
public class YX22X {
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=x*x-2.0*x;
System.out.println("Valor de y: " + y);
}
}
public class YX22X {
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=x*x-2.0*x;
System.out.println("Valor de y: " + y);
}
}