Course Solutions Uncategorized (Solved) : Following Code Wrote Big Main Function Package Dicegame Import Javautilrandom Public Class Q30191520 . . . .

(Solved) : Following Code Wrote Big Main Function Package Dicegame Import Javautilrandom Public Class Q30191520 . . . .

 

I have the following code which I wrote as a big mainfunction:

package dicegame;

import java.util.Random;

public class RollingDice

{

public static void main(String [] args) {

//Creating the list of 4 options available

System.out.println(“1. Roll a die”);

System.out.println(“2. Roll n dice”);

System.out.println(“3. Play a dice game!”);

System.out.println(“4. Exit”);

//getting input from the player to make menu choice

int choice = Console.getInt(“Make a choice”);

Random choice1 = new Random();

//if player selects option 1

if (choice == 1) {

int numberOfSides = Console.getInt(“Enter the number ofsides”);

int randomNumber = choice1.nextInt(numberOfSides)+1;//adding oneto the remove the possibility of rolling a zero

System.out.println(“Rolling…”);

System.out.println(“A ” + randomNumber + ” comes up”);

}

//if player selects option 2

else if (choice == 2) {

int numberOfSides =

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post