EL CLASICO DE SNAKE

SIGUE-LINEAS versión BETA

Sigue-lineas versión 2.0

martes, 25 de septiembre de 2007

PROGRAMA EN 'JAVA' COMPILANDO EN NETBEANS 5.0, EL CUAL COMPARA 5 NUMEROS Y LOS CLASIFICA:"POSITIVOS","NEGATIVOS" Y "CEROS".

import java.awt.graphics;
import javax.swing.japplet;

public class applet
{
public static void main (String args[])
{
String numero[];
numero=new String[6];
int x,posi=0,nega=0,cero=0,num[];
num=new int[6];
x=1;
while(x<=5)
{
numero[x]=JOptionPane.showInputDialog("numero"+x);
x++;
}
x=1;
while(x<=5)
{
num[x]=Integer.parseInt(numero[x]);
if(num[x]==0)
cero=cero+1;
if(num[x]<0)
nega=nega+1;
if(num[x]>0)
posi=posi+1;
x++;
}
JOptionPane.showMessageDialog(null,"cero = "+cero+"\n"+"positivo = "+posi+"\n"+"negativo = "+nega,"resultado",JOptionPane.INFORMATION_MESSAGE);

}
}