Este programa calcula la potencia, la raíz y la ecuación = x + √x
Main.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package operaciones;
/**
*
* @author usuario
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
Potencia.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author usuario
*/
public class Potencia{
public static void main(String args []) {
int x = 25;
double y;
double z;
if (x > 0){
System.out.println("Potencia = "+(x*x));
y= (double) x*x;
}
else{
System.out.println("El valor es incorrecto (debe ser mayor a cero)");
}
if (x >= 0){
y = Math.sqrt(x);
System.out.println("Raiz = "+(y));
}
else{
System.out.println("El valor debe ser menor o igual a cero");
}
if (x>=1){
y = Math.sqrt(x);
z = (double) x;
System.out.println("Ecuacion = "+(y+z));
}
else{
System.out.println("El valor debe ser mayor o igual que uno");
}
}
}
sábado, 24 de octubre de 2009
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario