Hi, I'm getting a

java.lang.NoSuchMethodError: main
Exception in thread "main"

error when trying to run this code. I have some variable being returned to the main method, but I don't know how else to write this program without doing that. Any help would be greatly appreciated. Thank you.

import java.util.Scanner;

public class Nim {
	
	public static void isValidEntry (int userstones,double totalstones,double computerstones){
		if (userstones>totalstones) {
			System.out.print("You can't do that! Please try again.\n");
			userTurn(totalstones,computerstones);
		} else {
		}
	}
	
	public static void drawStones(double totalstones,int userstones) {
		double computerstones;
		computerstones = 3*Math.random()+1;
		computerstones = (int)computerstones;
		isValidEntry(userstones,totalstones,computerstones);
		userTurn (totalstones,computerstones);
		main(totalstones,userstones,computerstones);
		
	}
	
	public static void computerTurn (double totalstones, double computerstones) {
		System.out.print("There are " + totalstones + " stones. The computer takes " + computerstones + " stones.");
	}
	
	public static void userTurn (double totalstones,double computerstones) {
		Scanner input = new Scanner (System.in);
		int userstones;
		
		System.out.print("There are " + totalstones + " stones. How many would you like? ");
		userstones=input.nextInt();
		isValidEntry(userstones,totalstones,computerstones);
		main (totalstones,userstones,computerstones);
		drawStones(totalstones,userstones);
		computerTurn(totalstones,computerstones);
		userTurn(totalstones,computerstones);
	}
	public static void main (double totalstones,int userstones,double computerstones) {
		totalstones = 16*Math.random()+15;
		totalstones = (int)totalstones;
		userTurn(totalstones,computerstones);
		totalstones-=userstones;
		totalstones-=computerstones;
		userTurn(totalstones,computerstones);
		if (totalstones==userstones) {
			System.out.print("The computer beats the player!");
		} else if (totalstones==computerstones) {
			System.out.print("The player beats the computer!");
		} else {
			userTurn(totalstones,computerstones);
		}
	}
}

Change name of your

public static void main(double totalstones, int userstones, double computerstones)

method to any other to avoid confusion. It's no necesary, but..
Listen to the Grn Xtrm.

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.