You are on page 1of 2

3)

package javaapplication1;
import java.io.*;
public class JavaApplication1 {
public static void main(String[] args)throws IOException{
double a,b,c,disc;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Ingrese coeficiente cuadratico:");
a=Double.parseDouble(in.readLine());
System.out.print("Ingrese coeficiente lienal:");
b=Double.parseDouble(in.readLine());
System.out.print("Ingrese la constante:");
c=Double.parseDouble(in.readLine());
disc= Math.pow(b,2) - 4 * a * c;
if (a != 0)
{
if (disc < 0)
{
System.out.println("tiene raices imaginarias");
}
else
{
double x1 = (-b + Math.sqrt(disc)) / (2 * a);
double x2 = (-b - Math.sqrt(disc)) / (2 * a);
System.out.println("x1=" + x1 + "x2=" + x2);
}
}
else
{
System.out.println("el coeficiente cuadratico debe ser diferente de 0");
}
System.out.println();
}
}

package javaapplication2;
import javax.swing.JOptionPane;
public class CAMBIODEVARIABLE{

public static void main(String[] args)


{
int v1,v2,x,y;

v1=Integer.parseInt(JOptionPane.showInputDialog("ingrese variable 1"));


v2=Integer.parseInt(JOptionPane.showInputDialog("ingrese variable 2"));
x=v1;
y=v2;
JOptionPane.showMessageDialog(null,"el valor de x es:"+y);
JOptionPane.showMessageDialog(null,"el valor de y es:"+x);

}
}

You might also like