Quiero hacer mi primer ejemplo con Java con esta operación:
Código
int x = 10;
int prueba = x**4 + x**3 + (1/2.0) * x**2 - x;
Lo he intentado hacer con este código completo en NetBeans 6.9.1.
Código
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package acaymo_01;
/**
*
* @author Hunter
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int x = 10;
int prueba = x**4 + x**3 + (1/2.0) * x**2 - x;
}
}
Me sale este error:
Citar
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - possible loss of precision
required: int
found: double
at acaymo_01.Main.main(Main.java:20)
Java Result: 1
GENERACIÓN CORRECTA (total time: 2 seconds)
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - possible loss of precision
required: int
found: double
at acaymo_01.Main.main(Main.java:20)
Java Result: 1
GENERACIÓN CORRECTA (total time: 2 seconds)
¿Cuál es el problema?
Lo que debo hacer es mostrar el resultado en pantalla.
Saludo.










Autor



En línea

