Java : Detectar Numeros Negativos y Positivos
/*
* 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.
*/
package ciclofor;
import javax.swing.JOptionPane;
/**
*
* @author Clases
*/
public class Ciclofor {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int numero=0,i=0;
for(i=0;i<3;i++ ){
do{
numero=Integer.parseInt(JOptionPane.showInputDialog("Ingresar numero"));
if(numero<0)
JOptionPane.showMessageDialog(null,"numero negativo");
}while(!(numero>0));
JOptionPane.showMessageDialog(null,"numero positivo");
}
}
}
Copyright : Inacap.