Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an application that rolls a pair of six-sided dice. Console Dice Roller Roll the dice? (y/n): y Die 1: 3 Die 2: 1

Create an application that rolls a pair of six-sided dice. Console Dice Roller Roll the dice? (y/n): y Die 1: 3 Die 2: 1 Total: 4 Roll again? (y/n): y Die 1: 1 Die 2: 1 Total: 2 Snake eyes! Roll again? (y/n): y Specifications You can use the random method of the Math class to generate a random number for a die like this: (int) (Math.random() * 6) + 1; Die 1: 6 Die 2: 6 Total: 12 Boxcars! Roll again? (y/n): n The application should display special messages for two ones (snake eyes) and two sixes (box cars). The application should use static methods to organize its code. The application should continue only if the user enters "y" or "Y" at the "Roll again?" prompt. Static methods private static String getUserChoice(Scanner sc, String prompt) { } private static int rollDie() { } private static void printDice(int die 1, int die2) { } private static void printSpecialMessage(int total) { }

Step by Step Solution

3.37 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Probability

Authors: Mark Daniel Ward, Ellen Gundlach

1st edition

716771098, 978-1319060893, 1319060897, 978-0716771098

More Books

Students also viewed these Programming questions

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago