Mod: lee las reglas del foro, no debes escribir en mayúsculas, los codigos ven en etiquetas GeSHi, las cosas van en su respuesctivo subforo... tema corregido y movidosaludos, tengo un error en mi ejercicio y me gustaria que me ayuden a encontrar el problema; es sobre la resolucion de una ecuacion cuadratica con applets...
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.applet.Applet;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.lang.Math;
/**
*
* @author
*/
/**
* Initialization method that will be called after the applet is loaded into
* the browser.
*/
Label l1, l2, l3, l4, l5
;
public void init() {
// TODO start asynchronous download of heavy resources
// --> DECLARANDO MIS ETIQUETAS Y CAJAS DE TEXTO
l4
= new Label("Raiz 1");
l5
= new Label("Raiz 2");
// --> AÑADIENDO BOTONES Y LABELS
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b); //-->BOTON
add(l4);
add(t4);
add(l5);
add(t5);
add(t6);
add(t7);
b.addActionListener(this);
// TODO overwrite start(), stop() and destroy() methods
}
//-->OPERACIONES LOGICAS DEL BOTON CALCULAR
// var a=num,b=num2,c=num3
double num
=Double.
parseDouble(t1.
getText()); double num2
=Double.
parseDouble(t2.
getText()); double num3
=Double.
parseDouble(t3.
getText()); // descarga en la variable d el valor de b^2-4ac
double d
=(Math.
pow(num2,
2.0)-(4*num
*num3
)); // calcula las raices de la ecuación
double raiz1
=((-num2
)+Math.
sqrt(d
))/(2*num
); double raiz2
=((-num2
)-Math.
sqrt(d
))/(2*num
); // compara la variable d
if (d==0)
{
// las raices son igulaes
t6.setText(""+raiz1);
t7.setText(""+raiz2);
}
if (d>0)
{
// tiene 2 raices diferentes
t6.setText(""+raiz1);
t7.setText(""+raiz2);
}
if (d<0) //--> CONDICION DE VALORES IMAGINARIOS
{
t6.setText("IMAGINARIA");
t7.setText("IMAGINARIA");
}
}
//---> POSICIONANDO ENCABEZADO
g.drawString("Resolucion Ecuación Cuadratica aX^2+bx+c=0", 10, 110);
g.drawString("Lenguaje de Programacion", 11, 130);
}
}