int RealMadrid = 0;
int Valencia = 0;
int Chelsea = 0;
int Barcelona = 0;
int ManchesterCity = 0;
for (int i = 0; i<20; i++) { // starts loop
String vote = JOptionPane.showInputDialog(null, " Please vote for your favorite soccer team "
+ "\n 1. Real Madrid"
+ "\n 2. Valencia"
+ "\n 3. Chelsea"
+ "\n 4. Barcelona"
+ "\n 5. Manchester City", "Team input", JOptionPane.QUESTION_MESSAGE);
if (vote.equals("1"))
{
RealMadrid++;
JOptionPane.showMessageDialog(null,"Real Madrid", "Student vote", JOptionPane.INFORMATION_MESSAGE);
}
else if (vote.equals("2"))
{ Valencia++;
JOptionPane.showMessageDialog(null,"Valencia", "Student vote", JOptionPane.INFORMATION_MESSAGE );
}
else if (vote.equals("3"))
{ Chelsea++;
JOptionPane.showMessageDialog(null, "Chelsea", "Student vote", JOptionPane.INFORMATION_MESSAGE);
}
else if (vote.equals("4"))
{ Barcelona++;
JOptionPane.showMessageDialog(null, "Barcelona", "Student vote", JOptionPane.INFORMATION_MESSAGE );
}
else if (vote.equals("5"))
{ ManchesterCity++;
JOptionPane.showMessageDialog(null, "Manchester City", "Student vote", JOptionPane.INFORMATION_MESSAGE);
}
else
{JOptionPane.showMessageDialog(null, "Invalid vote", "Warning", JOptionPane.WARNING_MESSAGE);}
}// end of loop
JOptionPane.showMessageDialog(null," The number of students who like Real Madrid is " + RealMadrid, "Team results", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null," The number of students who like Valencia is " + Valencia, "Team results", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null," The number of students who like Chelsea is " + Chelsea, "Team results", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null," The number of students who like Barcelona is " + Barcelona, "Team results", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null," The number of students who like Manchester City is " + ManchesterCity, "Team results", JOptionPane.INFORMATION_MESSAGE);
if (RealMadrid > 10){
JOptionPane.showMessageDialog(null,"Students love Real Madrid ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"Students don't like Real Madrid ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
if (Valencia > 10) {
JOptionPane.showMessageDialog(null,"Students love Valencia ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"Students don't like Valencia ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
if (Chelsea > 10) {
JOptionPane.showMessageDialog(null,"Students love Chelsea ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"Students don't like Chelsea ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
if (Barcelona > 10) {
JOptionPane.showMessageDialog(null,"Students love Barcelona ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"Students don't like Barcelona ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
if (ManchesterCity > 10) {
JOptionPane.showMessageDialog(null,"Students love Manchester City ", "Team results", JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,"Students don't like Manchester City ", "Team results", JOptionPane.INFORMATION_MESSAGE);
} * *