Question

Can someone help me put in a class of betting with my java program?

Can someone help me put in a class of betting with my java program?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

I can help but need problem statement of the betting game.

If the game is generic then the below steps would help you with the game.

Steps:
Variables
Hold variables for cashInPocket, amountYouStake

private int cashInPocket=1000; // some initial amount in pocket
private int amountYouStake; // take input from user for each bet

Taking Input
We can use Scanner inbuilt class to take user input in Java.

Example :
Scanner input = new Scanner(System.in);
System.out.println("How much amount you like to stake?");
amountYouStake = input.nextInt();

Generating random number:
Random rand = new Random();

Simulating a roll:

Simulating a random roll between from 1 to 100

int rollNumber = rand.nextInt(100-1) + 1;

Loop the game and make sure to take user consent to play or cashInPocket > 0
Decide who won or lost.
Remove amountYouStake if lost from you pocket.
Add amountYouStake if won to you pocket.

Make sure to put logic in different methods to make if clear.

for example:

// method to check if you have money in Pocket
public boolean hasMoneyInPocket(){
return cashInPocket > 0;
}

Let me know if you need more information on this.
Thanks.

Add a comment
Know the answer?
Add Answer to:
Can someone help me put in a class of betting with my java program?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java program called Flip. Write code that creates and populates an array of size 25 with random numbers between 1-50. Print the array. Print array in reverse.

  • Intro to Java. Can someone please help me answer this question. Create a java program playing...

    Intro to Java. Can someone please help me answer this question. Create a java program playing the game of craps with a random number generator. Write a method craps that plays the game of craps and it should return a 1 representing a win, a 2 representing a loss, and a 0 representing the need to toss the pair of dice again. The main method should ask how many games you wish to play then call the method craps. Main...

  • I need help with this. Can someone please show me the solution. Declaring and Initializing Java...

    I need help with this. Can someone please show me the solution. Declaring and Initializing Java Variables Summary In this lab, you declare and initialize variables in a Java program. The program file named NewAge.java, calculates your age in the year 2050. Instructions Declare an integer variable named newAge. Declare and initialize an integer variable named currentAge. Initialize this variable with your current age. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the...

  • can someone help me with this? i'm on my 135th hour of this program which is...

    can someone help me with this? i'm on my 135th hour of this program which is making me crazy thanks - CHEMICAL BONDING Drawing the MO energy diagram for a period 2 homodiatom Draw the molecular orbital (MO) electron diagram for the He, molecular ion. Be sure your diagram contains all of the electrons in the ion, including any core electrons. Energy 0 1 1 x 5 ? Explanation Check

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Create a method called printArray that prints the contents of the array using the for each...

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Create a method called printArray that prints the contents of the array using the for each...

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold their weights. Use Scanner to prompt for their name and weight and store in correct array. Compute and print the average of the weights entered using printf command. Use a loop to traverse and print the elements of each array or...

  • COMP Help (Java): Can someone please help me with this problem! Someone answered it but it...

    COMP Help (Java): Can someone please help me with this problem! Someone answered it but it was wrong. 1. Create an ExtArrayList<E> class by extending the ArrayListE> class to include the following methods and estimate the run-time complexity of each method. public ExtArrayList<E> append(ExtArrayList<E> ea) // appends the values in ea to the end of this ExtArrayList and returns the new ExtArrayList //example: this: {1,2,3} parameter : {4,5}, result {1,2,3,4,5} public boolean consecutivePair(E e1, E e2) // checks if this...

  • This is a cell molecular biology question from my class. Can someone please help me with...

    This is a cell molecular biology question from my class. Can someone please help me with this question? Please no diagrams or pictures from online copied and pasted here. I need a detailed explanation. Thank You! Please draw the five levels of M phase in a diploid cell (2n) where n=2.

  • would someone please kind enough to help me out on my intro to java study guide...

    would someone please kind enough to help me out on my intro to java study guide by helping me with some useful tips/ examples or anything on these questions. My grade is on the line and would really appreciate your help! Final exam study guide 13. truncating vs rounding - Where do you encounter truncation? Where do you encounter rounding? 14. Can you identify the following items in a Java source code example (using just syntax, usage, and naming convention)?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT