• 100% Satisfaction Guarantee

Raj, Engineer
Category: Homework
Satisfied Customers: 1281
Experience:  4 + Experiance in IT Industry
16752232
Raj is online now

# Write a program that allows a single Player (the user) to play

### Resolved Question:

Write a program that allows a single Player (the user) to play a simple two dice game of chance against a single Opponent (the computer).

Game Description:

There is a single Player (human), with two dice.

There is a single Opponent (computer), with two dice.

Each die is six sided, and each of its sides is labeled with a unique number from 1 to 6, we will call this the value of the die.

A game is made up of rounds, a single round is played as such:

The computer Opponent rolls it two dice.

The dice are displayed.

The Player rolls their two dice.

The dice are displayed

A determination is made as to who won the round, this determination is made via the following rules:

Larger values beat smaller values, same values are a tie.

A pair is when both dice have the same number on their top faces, the value of the pair is this common value.

A non-pair is then when both dice have a different number on their top faces, the major die is the one with the larger value and the minor die the one with the lesser value.

Any pair beats any non-pair.

Any two pairs are compared by their respective pair values.

Any two non-pairs are first compared by their major die values and only in the case of a tie in majors, are compared by their minor die values.

The result of the round (with respect to the Player) is announced.

The result of the round (with respect to the Player) is tallied, by increasing the number of player wins, ties, or loses by one.

The player decides if they wish to play another round.

When the game is over, the results of the game (how many rounds the player won, tied and lost) are announced.

Rules and Requirements:

You must model a pair of dice as two integers (one for each of the die) named major and minor respectively.

You must have one pair of die designated for the Opponent and one pair of die designated for the Player.

The value of the major die must be greater than or equal to the value of the minor die. Each time either or both are modified you must verify this condition and re-order them if necessary.

Given the following method heading, you must write the corresponding definition for a void return method that displays a brief accounting of the rules and format of your game.

// displays a brief accounting of the rules and format of the game
public static void welcome()

Given the following method heading, you must write the corresponding definition for a int return method that generates and returns a random number in the range of low to high inclusive.

// returns an int in the range [low, high]
public static int rollDie(int low, int high)

Given the following method heading, you must write the corresponding definition for a int return method that returns the larger of d1 and d2.

public static int majorDie(int d1, int d2)

Given the following method heading, you must write the corresponding definition for a int return method that returns the smaller of d1 and d2.

public static int minorDie(int d1, int d2)

Given the following method heading, you must write the corresponding definition for a void return method that prints the pair of dice (d1 and d2) to the screen, in some reasonable report format.

public static void printDice(int d1, int d2)

Given the following method heading, you must write the corresponding definition for a boolean return method that returns true if and only if d1 == d2.

public static boolean isPair(int d1, int d2)

Given the following method heading, you must write the corresponding definition for a int return method that determines the result of a single round of the game, (with respect to the Player).

// return: -1 -> Player lost; 0 -> tie; 1 -> Player won
public static int result(int oMajor, int oMinor, int pMajor, int pMinor)

Given the following function heading, you must write the corresponding definition for a void return method that generates a reasonable report of a game's outcome statistics.

// Report the games outcome statistics
public static void report(int wins, int ties, int loses)

Sample run(s):

miller.cs: Sample9

Welcome to Computer Dice
---------------------------------------------
Your opponent will first roll their two dice.
Next You will roll your two dice.

The outcome of each round will be based on
the values of your dice - high beats low,
pairs beat non-pairs.
---------------------------------------------

Opponent
--------
4 3

Player
--------
4 1
Sorry, you lose!

Do you wish to play again [y, n] : y

Opponent
--------
6 3

Player
--------
5 1
Sorry, you lose!

Do you wish to play again [y, n] : y

Opponent
--------
2 2

Player
--------
4 1
Sorry, you lose!

Do you wish to play again [y, n] : y

Opponent
--------
Submitted: 3 years ago.
Category: Homework
Expert:  Raj replied 3 years ago.
Hi there,

I will be helping yoi with the solution.
Can you please specify the programming language to be used along with the deadline?

Thank you
Customer: replied 3 years ago.
java and tomorrow at 5pm cst
Expert:  Raj replied 3 years ago.
I am sending an underprice reporting the new price based on urgency and amount of work to be done.
Customer: replied 3 years ago.
ok, how much?
Expert:  Raj replied 3 years ago.
I sent the underprice report for \$40
Customer: replied 3 years ago.
ok, sounds good
Expert:  Raj replied 3 years ago.
Ok ask the cistomer care to change the price to our agreed value..
Customer: replied 3 years ago.
Ok, I just did that. Will my answer be ready by 5pm today? Even if customer care doesn't get this fixed in time i can always just add a \$20 tip to make the value \$40.
Expert:  Raj replied 3 years ago.
Ok no problem you can add tip....
Also I will be providing the .java file. Will you be able to run it on your side?

Which software do you use....
Customer: replied 3 years ago.
Yes, I have eclipse
Expert:  Raj replied 3 years ago.
Ok got it
Expert:  Raj replied 3 years ago.
Ok at the End of Sample RUN I think something went missing.
Can you please post the sample run i.e. the last part of Question Once again....

Thank you
Expert:  Raj replied 3 years ago.

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Raj, Engineer
Category: Homework
Satisfied Customers: 1281
Experience: 4 + Experiance in IT Industry

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

### What Customers are Saying:

• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Previous | Next >
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
• This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
• Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
• I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
• Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
• Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
• He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX

• ### LogicPro

#### Satisfied Customers:

4925
Expert in Java C++ C C# VB Javascript Design SQL HTML
< Last | Next >

### LogicPro

#### Satisfied Customers:

4925
Expert in Java C++ C C# VB Javascript Design SQL HTML

### Manal Elkhoshkhany

#### Satisfied Customers:

4538
More than 5000 online tutoring sessions.

### Linda_us

#### Satisfied Customers:

3138
Post Graduate Diploma in Management (MBA)

### Chris M.

#### Satisfied Customers:

2602
Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

### F. Naz

#### Satisfied Customers:

2126
Experience with chartered accountancy

### Bizhelp

#### Satisfied Customers:

1887
Bachelors Degree and CPA with Accounting work experience