I need to create two public static void mains, however when trying to create "mainfunction", I run into the illegal start of expression. Please help.

import java.io.*;
import java.util.Scanner;

public class guessinggame

{

  public static void main (String []args)
  {

    Scanner scanner = new Scanner(System.in);
    System.out.println ("Guessing Game");
    System.out.println ("Do you want to play a ");
    System.out.println ("1. Easy game?");
    System.out.println ("2. Difficult game?");
    System.out.println ("3. Very difficult game?");

    int difficulty;
    do
    {
      System.out.println (" Make a choice; 1,2, or 3");


      difficulty = scanner.nextInt();

      if( difficulty < 1 || difficulty > 3 )
      {
        System.out.println ("Invalid Choice!");

      }




public class mainfunction
{
  public static void main (String [] args); 
  {
    while( difficulty < 1 || difficulty >3 );

    int numberguess = 1;

    if (difficulty == 1)
    {
      numberguess = 20 + (int)(Math.random () * (30 - 20 + 1));
    }

    if (difficulty == 2)
    {
      numberguess =  10 + (int)(Math.random () * (15 - 10 + 1));
    }

    if (difficulty == 3)
    {
      numberguess = 1 + (int)(Math.random () * (5 - 1 + 1));
    }

    System.out.println ("You have " + numberguess + " number of guesses");  


    int randomnumber;
    int userguess; 

    randomnumber = 1 + (int)(Math.random () * (100));
    System.out.println ("Secret number is " + randomnumber);

    System.out.println ("Please enter your guess.");
    userguess = scanner.nextInt(); 

    int count = 0;
    while ( userguess != randomnumber && count <= userguess )
    {  

      if (count >= userguess)
      {
        System.out.println ("You have used all of your guesses! Game over!"); 
      }

      if (userguess < 1 || userguess > 100)
      {
        System.out.println ("Invalid choice!");
      }
      if (userguess < randomnumber)
      {
        System.out.println ("The secret number is greater than your guess.");

      }                       

      if (userguess > randomnumber)
      {
        System.out.println ("The secret number is less than your guess.");
      }

      count = count + 1;

      System.out.println ("You've used " + count + " of your " + numberguess + " guesses.");
      System.out.println("Enter your next guess.");

      if (count >= numberguess)
        System.out.println ("Game Over! You have lost!  The secret number is " + randomnumber);

      userguess = scanner.nextInt(); 

    }


    if (userguess == randomnumber)
      System.out.println ( " Congrats, you've won!!!");

  }

they need to be in two seperate java files with their own names (equal to the name of the public class).
you can do it in one, but then you need one of the classes not to be public.
also: don't forget the closing brackets for your classes. don't create classes inside classes, unless we're talking about anonymous classes.

but, now a question ... why do you need two main methods? that makes no sense to me at all.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.