Question: Create a program that will to roll a single die (1, 2, or 3) each roll value it out 1) ask the user how many
Create a program that will to roll a single die (1, 2, or 3) each roll value it out 1) ask the user how many times do we nees 2) roll a die that many times printing 3) compute the sum of all rolls and print Sample output: How many rolls do you want? (enter 1, 2, or 2 Your first number is 5 Your second number is 1 Sum6 OR How many rolls do you want? (enter 1, 2, or Your first number is 3 Your second number is 3 Your third number is 6 Sum 12 Your program should have the method roll( output a random integer between 1 and 6 when called It should also make sure that the user enter and if it's a wrong number, ask him to enter that will (inclusive) a number , 2, or3 it again. import java.util.Scanner; public class SumofRolls f // Implement a method roll() that returns // integer between and 6 (inclusive) public static int roll) a random when called public static void main(String[] args) f //1. Ask the user how many rolls does she want (1, 2, or 3) //2. If the user's input is not 1, 2, or 3, ask her to enter it again: //3. Roll the die the number of times requested by the user // Print out each roll output and the sum of all rolls at the end. // Use an if statement: // f ( numberOfRolls-=1 ) {.. // else if (numberofRolls 2) // ) and so on
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
