HI, i'm new in JAVA
i creating a "GUESS NUMBER GAME"..
which allow user 3 changes to guess..
i'm new to java so i need a simple coding...
i has done the part but i dun wan to combine all function in main...
this is my problem, i hope u can solve to me...
this is my coding... pls look forward it..

import javax.swing.JOptionPane;
public class game1
public static void main (String args[])
int rollOfDice, num, x;
String output,userNum;

//generate a random number betwwen 1 and 6 inclusive
rollOfDice = (int)(Math.random()*6)+1;
output = "You rolled a "+rollOfDice;

//print msg
JOptionPane.showMessageDialog(null,output,"Random Number Demo",JOptionPane.INFORMATION_MESSAGE);

userNum = JOptionPane.showInputDialog ("Please Guess the number");
num = Integer.parseInt(userNum);

if (num == rollOfDice)
output = "Congratulation";
for (x=1;x>3;x++)
output = "Try again";
//output = "You are lose";
}while(num != rollOfDice);


Have you looked at examples of functions and how they are structured?