How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Raj Your Own Question

Raj
Raj, Engineer
Category: Homework
Satisfied Customers: 1259
Experience:  4 + Experiance in IT Industry
16752232
Type Your Homework Question Here...
Raj is online now
A new question is answered every 9 seconds

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)

Your program may use additional methods if desired.

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: 1 year ago.
Category: Homework
Expert:  Raj replied 1 year 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 1 year ago.
java and tomorrow at 5pm cst
Expert:  Raj replied 1 year ago.
I am sending an underprice reporting the new price based on urgency and amount of work to be done.
Customer: replied 1 year ago.
ok, how much?
Expert:  Raj replied 1 year ago.
I sent the underprice report for $40
Customer: replied 1 year ago.
ok, sounds good
Expert:  Raj replied 1 year ago.
Ok ask the cistomer care to change the price to our agreed value..
Customer: replied 1 year 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 1 year 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?

Let me know about that...
Which software do you use....
Customer: replied 1 year ago.
Yes, I have eclipse
Expert:  Raj replied 1 year ago.
Ok got it
Expert:  Raj replied 1 year 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 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Raj, Engineer
Category: Homework
Satisfied Customers: 1259
Experience: 4 + Experiance in IT Industry
Raj and 10 other Homework Specialists are ready to help you

JustAnswer in the News:

 
 
 
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.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...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
< Last | 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
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience