Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Dice game program in java

04/10/2021 Client: muhammad11 Deadline: 2 Day

Please i need helpe with this JAVA code.

Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows:

Problem Statement

One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a

7 or 11, it is called a natural. The player who rolled the dice wins.

2, 3 or 12, it is called . The player who rolled the dice loses.

If the player’s first roll is any other number (4, 5, 6, 8, 9, or 10), the bet is not

immediately decided. Instead, the number that the player rolled becomes the point and he continues to roll the dice until either he rolls the point a 2nd time, in which case he wins, or he rolls a 7, in which case he loses. For example, suppose a player’s 1st roll is a 6. Then 6 becomes the point. He must roll again. If his next roll were a 3, he would have to roll a 3rd time. The point remains 6. He continues to roll the dice until he either gets a 6 (a win) or a 7 (a loss).

When a player wins, he collects the bet, and gets to keep the dice and take another turn. Then the play begins again with rule (1)

When a player loses, his opponent collects the money that was bet and it becomes the opponent’s turn to roll the dice. The opponent starts play again with rule (1)

For this program, simulate a craps game for a total of at most 20 wagers. That is, the first player rolls the dice until he either wins or loses. That is the first wager. The winner then takes the dice, and rolls until the second wager is decided. And so on, for a total of 20 wagers. However, if one of the gamblers loses all of his money before the 20th wager, end the simulation at that point.

Assume that each player starts out with a balance of $1000. Assume also that when player 1 is rolling, he always bets $100 on each wager. However, player 2 believes in luck and uses a strategy of his own creation. When he has the dice and it is his turn to decide how much to bet, he considers how much money he has. If he has at least as much money as he had when the game began, he decides his luck is good and bets $150. If he has less money than when the game began, he decides his luck is bad, and only bets $50 on that particular wager. Player 1 always rolls the dice first in this simulation.

You must use pseudo-random number generator to simulate a dice roll. You can use a method named GenerateRandomNumber to simulate the roll of one die with maximum roll of 6. Since the game is played with two dice, to simulate one roll you will have to generate two numbers by calling GenerateRandomNumber twice and then adding the two numbers together.

Your program must print out a roll-by-roll description of what happens as the game is played on the console and to a file named game.txt.

Note: your program must be user-friendly and intuitive. This is a part of your grade. In other words, even if your program does everything the problem statement states, your grade may be reduced because of difficulty to use it.

Input

This program uses no input

Output

A roll-by-roll description of what happens as the game is played should be print out on the console and should be written to a file as well.

******************************************************************** Wager 1 : Bet is $100
Player 1 is rolling the dice
The roll is 2

That is ! Player 1 loses.
Currently, Player 1 has $900 and Player 2 has $1100.

********************************************************************
Wager 2 : Bet is $150
Player 2 is rolling the dice.
The roll is a 6. The point is 6. Player 2 rolls again. The roll is a 5. The point is 6. Player 2 rolls again. The roll is a 6. That is the point! Player 2 wins. Currently, Player 1 has $750 and Player 2 has $1250.

********************************************************************
Your output need not look exactly like this, but should be at least as easy to read. At a minimum, for each wager you must print which player is rolling the dice, and the amount of the bet. Then simulate rolling the dice, and print the result of each roll, until the winner is determined. At the end of each wager, print who won, and a running total of how much money each player has. Note that it's possible that a gambler could end up with a negative amount of money, if he or she does not have enough money left to pay the full amount of the final bet.

Use of Methods, Parameters, Modularity, Design, etc.

Part of your grade on this and ALL future programming projects in this course will be determined by how well you use multiple functions and parameter passing appropriately and how well you design a modular and functionally cohesive program using the principles discussed in class. Large grade point penalties can be incurred for not setting up a modular, well designed program structure. This emphasizes good program structure, design, and fundamental software engineering principles.

In this project, you must at least define and call the following 4 methods:

public static int GenerateRandomNumber(); public static int RollDice();

public static String DecideWhoWin(int dice_player1, int dice_player2, PrintWriter pw);

public static void WriteToFile(PrintWriter pw, String data);

public static void AnnounceFinalWinner(int money_player1, int money_player2, PrintWriter pw)

This what i have done so far

public class CrapsGame{
static int balance=1000,p1bet=100,p2bet=150,sum,roll,dice1,dice2,Player1,Player2,sumOfDice;
static String P1="Player 1",P2="Player 2";
static File file=new File("game.txt");
static PrintWriter pw;
enum Status{CONTINUE,WON,LOST};
static Status gameStatus;
public static void main(String[] args) throws IOException{
int i=GenerateRandomNumber();
System.out.println("Wager 1: Bet is $"+p1bet);
System.out.println(P1+" is rolling the dice");
System.out.println("The roll is "+i);
sumOfDice=RollDice();
switch(sumOfDice){
case 7:
System.out.println("You win");
gameStatus=Status.WON;
break;
case 11:
System.out.println("You win");
gameStatus=Status.WON;
break;
case 2:
System.out.println("That is ! Player loses.");
gameStatus=Status.LOST;
break;
case 3:
System.out.println("That is ! Player loses.");
gameStatus=Status.LOST;
break;
case 12:
System.out.println("That is ! Player loses.");
gameStatus=Status.LOST;
break;
default:
System.out.println("The roll is a "+i+" The point is "+i+". Player 2 rolls again.");
gameStatus=Status.CONTINUE;
break;
}
while(gameStatus==Status.CONTINUE){
sumOfDice=RollDice();
}

}
public static int GenerateRandomNumber(){

// Generate a random number between 1 to 6
roll=(int) (1 + Math.random()*6);
return roll;
}
public static int RollDice(){
dice1=GenerateRandomNumber();
dice2=1+GenerateRandomNumber();
sum=dice1+dice2;
return sum;

}
public static String DecideWhoWin(int dice_player1,int dice_player2,PrintWriter pw) throws IOException{
return null;

}
public static void WriteToFile(PrintWriter pw,String data){


}
public static void AnnounceFinalWinner(int money_player1,int money_player2,PrintWriter pw){
}
}

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Top Academic Tutor
Coursework Assignment Help
Instant Assignment Writer
A Grade Exams
A+GRADE HELPER
Chartered Accountant
Writer Writer Name Offer Chat
Top Academic Tutor

ONLINE

Top Academic Tutor

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$35 Chat With Writer
Coursework Assignment Help

ONLINE

Coursework Assignment Help

You can award me any time as I am ready to start your project curiously. Waiting for your positive response. Thank you!

$39 Chat With Writer
Instant Assignment Writer

ONLINE

Instant Assignment Writer

I have read your project details. I can do this within your deadline.

$40 Chat With Writer
A Grade Exams

ONLINE

A Grade Exams

I have read your project details. I can do this within your deadline.

$37 Chat With Writer
A+GRADE HELPER

ONLINE

A+GRADE HELPER

I am known as Unrivaled Quality, Written to Standard, providing Plagiarism-free woork, and Always on Time

$36 Chat With Writer
Chartered Accountant

ONLINE

Chartered Accountant

I will cover all the points which you have mentioned in your project details.

$37 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

English short story 300 words - PHYS lab - Exercise 5 12 analysis of inventory errors lo a2 - November night norman maccaig - John bennett architect southwold - List the commands used during your eigrp troubleshooting process - Coreless induction furnace diagram - Siemens 6es7 135 4fb01 0ab0 manual - Module two exam introduction to construction math answers - Www codeblocks org downloads 26 - What was jonathan kozol’s impression of the poorly funded schools he visited in urban chicago? - ISSC341 - Class in america gregory mantsios analysis - Electromagnetism Exam. 3 problems, 100 minutes. 7-9PM CDT time. - Thesis statement on fake news - Brandon king the american dream essay - Esma guidelines 10 788 - Professional thesis writing service - Warfarin resistance may be seen in patients with vcorc1 mutation, leading to - Lae fridge controller manual - Cryptography and Network Security - Amdocs order management system - Biology- Lab- Drawing - Fordinsure co uk drive away cover - Knauf 76 x 3000mm steel wall track - First stage allocation in activity based costing - The watch company manufactures trendy - Emotive language examples list - Positive interdependence and knowledge sharing - BI A - MBA 599 - Financial ACTIVITY Ratios - Which itil process uses mean time between failures mtbf - Films for the humanities & sciences - Courtroom participant chart - Non commercial segment definition - Ideal citizen in a totalitarian government - Scientific method game walk the plank - Georgia furniture mart formerly underpriced furniture - Montgomery Bus Boycott - Book value per share of common stock of a manufacturing company - West parley memorial hall - John hunter hospital neurologists - Finance questions-9 - Advantages of a multicultural society and labor force - Woodlands quaker care home - Ethical and religious directives for catholic health care services 2016 - Analyzing and visualization data - Research paper - Essay - Hydraulic tools with names - Calcium carbonate and vinegar balanced equation - How to calculate death rate per 100 000 - Smoke alarm compliance certificate template qld - The lancaster corporation's income statement - Franken and davis he only took tips - Ana scope and standards of practice - How to calculate average stockholders equity - Hfs loanadministration - Choose one Conversation - Dismissal of school on an october afternoon - The birthmark sparknotes - Partial income statement discontinued operations - Eaton easy 821 dc tc manual - Castle medical centre kenilworth - Unit I Case Study, Unit II Journal, Unit II Essay - Technology governance plan - Analayzing and visualizing data - Hydrogen peroxide and baking soda chemical equation - Econ 214 exam 2 - MGT312T Week. 2 Apply Self-Assessment Reflection - Write a argumentative essay discussing how sports influences or affects society/culture - You have observed the following returns over time - Homeostasis amoeba sisters worksheet - Street of the lifted lorax - Financial statement family court - Tangent galvanometer earth's magnetic field - 107wk1 - Scyon axent trim sizes - Table 2: part 3 - photosynthesis data - How many different tests (i.e., scripts) did your intense scan perform? - Myed university of edinburgh - Characteristics of beowulf with quotes - Founds funeral home west chester - Eoi for construction project - CLA 2 Comprehensive Learning Assessment 2 – CLO 5, CLO 6, CLO 7 - Activity based cost allocation - Claritas mybestsegments zip code lookup - Types of reinforcement ppt - Economics Tuition - Locate the chiral center s in the following compound - In diverse cultures and ses groups, insecurely attached infants tend to have mothers who - Healer baskar books online - Is the sovereign state in decline in an age of globalisation? - Melbourne car world - Healthcare Management - Three tall women monologue - The illusion of taking charge learning disability - 2 laws of reflection - At&t inventory turnover - Body recomposition jeff nippard pdf - Consumer behavior case study answers