-2

For a beginning class for coding in Java SE (using NetBeans 8.1 IDE). What I am trying to do is this

Main file immediately initializes and goes to playDice, which checks the players current balance, asks for a bet amount, and if the current balance is greater than 0, and the bet amount is less than or equal to the current balance, it initializes the method public static int determineWinnings(.....) . This right here is my problem. This is my current code for trying to get the program to initialize determineWinnings.

if (balance >= 0 && balance >= betAmmount) {
    determineWinnings();
}

With that code, I get an error message saying this . What is the fix?

Full code, if needed, for a reference

package dicegame;

import static dicegame.UserInput.*;

public class DiceGame {

public static void main(String[] args){
    System.out.println("Lets play the dice game!");

    System.out.println("Loading");
    playDice();
    }


public static void playDice(){
    System.out.println("Hello, please input the ammount you will like to bet!");
    int balance=1000;
    int betAmmount=getInt();

    if(balance>=0 && balance>=betAmmount){
        determineWinnings();
    }
    else if(balance<=betAmmount){
        System.out.println("You can not bet in this game! Your bet can not be greater than your current balance!");
    }
    else if(balance==0){
        System.out.println("You can not bet in this game! You have no money left!");
    }        
}         


public static int determineWinnings(int balance, int betAmmount){
    int die1 = (int)(Math.random()*6) + 1;
    int die2 = (int)(Math.random()*6) + 1;

    System.out.println("Rolling...");
    System.out.println("You rolled a " + die1);
    System.out.println("You rolled a " + die2);


    if(die1==die2){
        if(die1==1 && die2==1){
            System.out.println("CONGRATULATIONS! YOU HIT THE JACKPOT! Your current balance will be multiplied by 12!");
            balance=balance*12;
            System.out.println("Your current balance is" + balance);
        }
        else if(die1==2 && die2==2){
            System.out.println("CONGRATULATIONS! You won! Your current balance will be doubled!");
            balance=balance*12;
            System.out.println("Your current balance is" + balance);
        }                        
        else if(die1==3 && die2==3){
            System.out.println("CONGRATULATIONS! You won! Your current balance will be tripled!");
            balance=balance*12;
            System.out.println("Your current balance is" + balance);
        }
        else if(die1==4 && die2==4){
            System.out.println("CONGRATULATIONS! YOU HIT THE JACKPOT! Your current balance will be quadrupled!");
            balance=balance*12;
            System.out.println("Your current balance is" + balance);
        } 
        else if(die1==5 && die2==5){
            System.out.println("CONGRATULATIONS! YOU HIT THE JACKPOT! Your current balance will be quintupled!");
            balance=balance*12;
            System.out.println("Your current balance is" + balance);
        }
        else if(die1==6 && die2==6){
            System.out.println("CONGRATULATIONS! YOU HIT THE JACKPOT! Your current balance will be sextupled!");
            balance=balance*12;
            System.out.println("Your current balance is" + balance);
        }
    }        
    else{
        balance=balance-betAmmount;
        System.out.println("You lost! Your new balance is" + balance);
    }  
    return 0;
}

}

Turing85
  • 18,217
  • 7
  • 33
  • 58
brett w
  • 1
  • 1
  • look at what your `determineWinnings` method expects as parameters and how you are calling it (aka. read what the error says) – UnholySheep Sep 07 '17 at 18:49
  • You declared `determineWinnings(int balance, int betAmmount)` so it *requires* two `int` values, but you are not passing any when you call it via `determineWinnings()`. – Pshemo Sep 07 '17 at 18:49
  • Your method expects two integers: `determineWinnings(int balance, int betAmmount)` You're passing it no integers: `determineWinnings()` You need to supply values to the method when you call it. For example: `determineWinnings(balance, betAmount)` – David Sep 07 '17 at 18:50

2 Answers2

1

You need to pass balance and betAmount to determineWinnings(...):

if (balance >= 0 && balance >= betAmmount) {
    determineWinnings(balance, betAmount);
}
Turing85
  • 18,217
  • 7
  • 33
  • 58
Alejandro C.
  • 3,771
  • 15
  • 18
0

You declared determineWinnings as

public static int determineWinnings(int balance, int betAmmount)

yet you are calling it without any arguments

determineWinnings()

You should be passing in two ints.

Andrew H
  • 453
  • 1
  • 3
  • 8