Sample java code (JOptionpane)

Posted on at


import javax.swing.JOptionPane;

public class Count

{

public static void main(String []args){

String number=" ";

int num;

int ctr=1,positive=0,negative=0;

while(ctr<6)

{

number=JOptionPane.showInputDialog("Enter number:");

ctr++;

num=Integer.parseInt(number);

if(num>=0)

positive++;

else

negative++;

 

}

JOptionPane.showMessageDialog(null,"The total number of positive is:" + positive);

JOptionPane.showMessageDialog(null,"The total number of negative is:" + negative);

}

}


TAGS:


About the author

160