I have this program I'm writing. I need help with the bet part of the program. I'll give you an idea of what I'm doing:
The player starts with $500. He can bet between 0 and his current amount left on next turn. If he bets 0 the game is over and you should print his remaining amount.He rolls 1 12 sided die. The computer rolls 2 6 sided dice.Add the 2 computer dice together.Compare the numbers. If the player number is bigger he wins his bet. If the computer number is bigger the player loses his bet. If the numbers are the same, but over 7 the player wins his bet and if the numbers are the same, but the numbers are lower than 7 the computer wins the bet. If the number is 7, the bet is a tie and the total will not change.

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import javax.swing.*;
import java.text.DecimalFormat;
import java.util.*;

public class DiceGame1  extends Frame
{
    public static void main(String[] args)
    {
    //declare variables
    int startingAmount;// starting amount 
    double playerBet;// what the player bets
    int computerRoll;//the computer's roll
    int computerDie; //computers overall total rolls 
    int playerRoll;//the player's roll
    double aRandomNumber;
    double amount;


    //Starting Input
    startingAmount = 500;
    playerBet=0;
    amount=0;

    System.out.println("Starting Value of $" +startingAmount);
     JOptionPane.showInputDialog(null,"Enter Your Bet:");

    //Random number's generator for player.
     playerRoll = 1+(int)(Math.random()*12);
     System.out.println("Your Roll:" +playerRoll);

    //Random number's generator for the computer.
    computerRoll = 1+(int)(Math.random()*6);
    computerDie = computerRoll + computerRoll;
    System.out.println("Computer's Roll:" + computerDie );

    //Calculation
    if(playerRoll > computerRoll)
    {
    System.out.println("YOU WIN !");
    } 
    else if (computerRoll > playerRoll)
    {
    System.out.println("YOU LOSE");
    }

    if((computerRoll = playerRoll) >7)
    {
    System.out.println("Winner");
    }
    else if((computerRoll= playerRoll) <7)
    {
    System.out.println("Loser");
    }
    else if((computerRoll = playerRoll)=7)
    {
    System.out.println("Tie");
    }
    }}

Please edit your post and properly align the code. The nesting of statements within {} should be indented 3-4 spaces. The posted code is not readable with all the statements starting in the first column.

Can you explain what problems you are having with the code? Post the full text of any error messages.

Post the program's output and add some comments explaining what is wrong with the output and add some comments showing what you'd like the output to be.

you need to check your if statements i made some changes and left out others:

        if (playerRoll > computerRoll) {
            System.out.println("YOU WIN !");
        } else if (computerRoll > playerRoll) {
            System.out.println("YOU LOSE");
        }
        if ((computerRoll == playerRoll) || playerRoll > 7) {
            System.out.println("Winner");
        } else if ((computerRoll == playerRoll) && playerRoll < 7) {
            System.out.println("Loser");
        }

ohk, I checked them and now I just dont know how to come up with the bet portion of the program. I dont know where to go from here:

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import javax.swing.*;
import java.text.DecimalFormat;
import java.util.*;

public class DiceGame1  extends Frame
{
    public static void main(String[] args)
    {
    //declare variables
    int startingAmount;// starting amount 
    double playerBet;// what the player bets
    int computerRoll;//the computer's roll
    int computerDie; //computers overall total rolls 
    int playerRoll;//the player's roll
    double aRandomNumber;
    double amount;


    //Starting Input
    startingAmount = 500;
    playerBet=0;
    amount=0;

    System.out.println("Starting Value of $" +startingAmount);
     JOptionPane.showInputDialog(null,"Enter Your Bet:");

    //Random number's generator for player.
     playerRoll = 1+(int)(Math.random()*12);
     System.out.println("Your Roll:" +playerRoll);

    //Random number's generator for the computer.
    computerRoll = 1+(int)(Math.random()*6);
    computerDie = computerRoll + computerRoll;
    System.out.println("Computer's Roll:" + computerDie );

    //Calculation
    if(playerRoll > computerRoll)
    {
    System.out.println("YOU WIN !");
    } 
    else if (computerRoll > playerRoll)
    {
    System.out.println("YOU LOSE");
    }

    if((computerRoll == playerRoll) || playerRoll>7)
    {
    System.out.println("Winner");
    }
    else if((computerRoll== playerRoll) ||playerRoll <7)
    {
    System.out.println("Loser");
    }
    else if((computerRoll == playerRoll) && playerRoll <7)
    {
    System.out.println("Tie");
    }
    }}

how to come up with the bet portion of the program

Can you describe what you want the "bet portion" of the program to do?

Yes, I need it to be able to accept user input. The user should input their bet, and if the user enters 0 for the bet it just prints out remaining amount. If the user enters a bet other than 0 it needs to eventually if the user won or not, add or subtract it to there starting amount and print out ther new amount they have after that roll.

See the Scanner class for an easy way to get input from a user. It has several methods to chose from that will read input from the console (from System.in)

I do not get why the dice value is doubled for computer, on first post you describe two die.

ohk, thanks.
And that's just what the program asked for: It says to The player starts with $500. He can bet between 0 and his current amount left on next turn. If he bets 0 the game is over and you should print his remaining amount.He rolls 1 12 sided die. The computer rolls 2 6 sided dice.Add the 2 computer dice together.Compare the numbers. If the player number is bigger he wins his bet. If the computer number is bigger the player loses his bet. If the numbers are the same, but over 7 the player wins his bet and if the numbers are the same, but the numbers are lower than 7 the computer wins the bet. If the number is 7, the bet is a tie and the total will not change.

But you are doubling the one computer dice, not doing two random numbers. Then for result you compare against single computer dice computerRoll and line 50 is missing else before if.

You are doing two random numbers, because the computer rolls 2 dice. That's why I added them together to get the overall dice amount.

Do the computer's rolls ever total to an odd number? Shouldn't the total include all the numbers from 2 to 12, including the odd numbers?

Yes they should, I'm so lost on what to do.

Look at the code.
Compare the player's roll to the computer's.

I did, didn't I? In the if statement?

Sorry, I meant to say: look at how the player's roll is computed and compare it to how the computer's roll is computed.

Yes I understand that, but the players roll is computed by doing the random number and using 12 because of the 1, 12 sided dice. I computer the computers roll with the random number and used times 6 because they are rolling a 6 sided dice. Then I added the two computer rolls together to get on dice. Because the program calls for the computer rol to be added twice

If you double the value of one roll you will never get an odd value. You must either compute the total as done for the player or roll two times and add the two rolls together,

Oh, ohk very true. Sorry it took so long to realize what you were saying. I fixed it.

//Random number's generator for player.
     playerRoll = 1+(int)(Math.random()*12);
     System.out.println("Your Roll:" +playerRoll);

    //Random number's generator for the computer.
    computerRoll = 2+(int)(Math.random()*6);

    System.out.println("Computer's Roll:" + computerRoll );

Can you help me interpret the bet part into the program? I'm lost about how to add it in

What values do you want for the variable: computerRoll?
Check that your code on line 6 generates what you want.
Write a small loop that loops 20 times with that code inside it and print out the values of computerRoll to see what you get

Done for tonight. Back tomorrow.

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.