import javax.swing.JOptionPane;

public class Vote {

public static void main( String args[] )
{

String x;
int total= 0, output= 0;

do{

x=
JOptionPane.showInputDialog( "Enter JONES or SMITH for your vote" );

if (x.equalsIgnoreCase( "JONES" ))
total += 1;

else if ( x.equalsIgnoreCase( "SMITH" ))
output += 1;

else if ( x.equalsIgnoreCase( "stop" ))
break;

else
JOptionPane.showMessageDialog( null, "enter a valid vote", "ERROR", JOptionPane.WARNING_MESSAGE );

} while ( ! x.equalsIgnoreCase( "stop" ));

if ( total < output )
JOptionPane.showMessageDialog( null, "SMITH wins with " + output + " votes\nJONES lost with " + total +  " votes", "RESULTS", JOptionPane.INFORMATION_MESSAGE );

if ( output < total )
JOptionPane.showMessageDialog( null, "JONES wins with " + total +  " votes\nSMITH lost with " + output + " votes", "RESULTS", JOptionPane.INFORMATION_MESSAGE );

if ( output == total)
JOptionPane.showMessageDialog( null, "It is a tie with " + total + " votes a piece", "RESULTS", JOptionPane.INFORMATION_MESSAGE );

System.exit(0);
}
}
Hosted by www.Geocities.ws

1