Hey Everyone,
Started Java for couple of months now and still struggling to put things together.Any assistant will be highly appreciated.
I wanted to display an initial menu screen with the following set of options:
1. Display the current score for each possible response.
2. Vote
3. Quit the program.
I wanted to display the user selects lets say the user selected option two, the program will display the question and the four possible responses eg Who will win the Champions League in 2010/11? "
+ "\n 1. Real Madrid"
+ "\n 2. Barcelona"
+ "\n 3. Chelsea"
+ "\n 4. Manchester United.
The user will then enter a response and the response will be recorded in the program.
this is what i have coded so far'
import javax.swing.JOptionPane;
import java.io.*;
public class ChampionLeague {
static public int menu(String message, String menuOptions[]){
int choice;
int Quit = 0;
String optionSelected = " ";
String outputString = " ";
//Show menu and get users choice
choice = JOptionPane.showOptionDialog(null, "Display the current score for each possible response \n"
+ "2. Vote \n "
+ "3. Quit the program ");
return choice;
int vote = 4;
String game [][] = new String [choice][choice];
game [0][0] = "Real Madrid ";
game [0][1] = "250 "; // display current vote
game [1][0] = "Barcelona ";
game [1][1] = " 320 ";
game [2][0] = "Chelsea ";
game [2][1] = "140 ";
game [3][0] = "Manchester United ";
game [3][1] = "300 ";
for(int i = 0; i < choice; i++){
String name = game[i][0];
String marks = game[i][1];
}
JOptionPane.showMessageDialog(null, outputString );
String input = JOptionPane.showInputDialog(" Who will win the Champions League in 2010/11? "
+ "\n 1. Real Madrid"
+ "\n 2. Barcelona"
+ "\n 3. Chelsea"
+ "\n 4. Manchester United");
int x = Integer.parseInt(input);
if (x == 1)
outputString = outputString + "You entered Real Madrid";
else if (x == 2)
outputString = outputString +("You Entered Barcelona");
else if (x == 3)
outputString = outputString + ("You Entered Chelsea");
else if (x == 4)
outputString = outputString + ("You Entered Manchester United");
else
outputString = outputString + ("Invalid input\nEnter Valid Vote 1 - 4 ");
optionSelected = Integer.toString(x);
System.out.println(x);
JOptionPane.showMessageDialog(null, outputString );
}//end of maim
}// end of class