// Codificado por Beastieux
public class DSCDetectorDeSigno {
void Detectar(int a) {
if (a < 0)
System.out.println("La variable: " + a + " es NEGATIVA");
else if (a > 0)
System.out.println("La variable: " + a + " es POSITIVA");
else
System.out.println("La variable: " + a + " es CERO");
}
public static void main(String[] args) {
int j = 0;
DSCDetectorDeSigno variable = new DSCDetectorDeSigno();
if (args.length == 0)
System.out.println("Debe ingresar parámetros");
else {
for (int i = 0; i < args.length; i++) {
try {
j = Integer.parseInt(args[i]);
variable.Detectar(j);
} catch (NumberFormatException e) {
System.out.println("El valor ingresado no es un número válido: " + args[i]);
}
}
}
}
}
Compilar: javac DSCDetectorDeSigno.java
Ejecutar: java DSCDetectorDeSigno -10
Pueder ir al artículo principal:
Códigos Sencillos hechos en Java
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?