. Create a program that does the following. Prompt a user to enter the number of sides they would like on a pair of dice
Posted: Wed Apr 27, 2022 3:13 pm
I have the base of the code down but cant figure out how to the
integers without printing the whole thing. Java
import java.util.Scanner;
public class Dice
{
public static void main(String[] args)
{
Scanner console = new
Scanner(System.in);
Scanner input = new
Scanner(System.in);
int side;
int roll;
side = sideprompt();
while( rollprompt() !=
-99)
{
roll = rollprompt();
dice(roll);
}
}
public static int sideprompt
()
{
Scanner console = new
Scanner(System.in);
System.out.println("Enter the
number sides for your dice");
int sideTemp =
console.nextInt();
return sideTemp;
}
public static int rollprompt
()
{
Scanner console = new
Scanner(System.in);
System.out.println("How many
times would you like to roll the dice (-99 to quit)?");
int rollTemp =
console.nextInt();
return rollTemp;
}
public static void dice(int
rolls)
{
int rand =
0;
if ( rolls
!= -99)
{
for (int i=0; i<rolls; i++)
{
rand = 1+(int)(Math.random()*ss);
System.out.println("You rolled a " + rand
+" and a " + rand);
}
}
else
{
System.out.println("You have quit the
program");
}
}
}
. Create a program that does the following. Prompt a user to enter the number of sides they would like on a pair of dice. • Prompt a user to enter the number of times they would like to roll the dice. • Allow the user to keep rolling the dice until they press '99'. Each prompt must be a separate method. Displaying the results must be a separate method. . .
integers without printing the whole thing. Java
import java.util.Scanner;
public class Dice
{
public static void main(String[] args)
{
Scanner console = new
Scanner(System.in);
Scanner input = new
Scanner(System.in);
int side;
int roll;
side = sideprompt();
while( rollprompt() !=
-99)
{
roll = rollprompt();
dice(roll);
}
}
public static int sideprompt
()
{
Scanner console = new
Scanner(System.in);
System.out.println("Enter the
number sides for your dice");
int sideTemp =
console.nextInt();
return sideTemp;
}
public static int rollprompt
()
{
Scanner console = new
Scanner(System.in);
System.out.println("How many
times would you like to roll the dice (-99 to quit)?");
int rollTemp =
console.nextInt();
return rollTemp;
}
public static void dice(int
rolls)
{
int rand =
0;
if ( rolls
!= -99)
{
for (int i=0; i<rolls; i++)
{
rand = 1+(int)(Math.random()*ss);
System.out.println("You rolled a " + rand
+" and a " + rand);
}
}
else
{
System.out.println("You have quit the
program");
}
}
}
. Create a program that does the following. Prompt a user to enter the number of sides they would like on a pair of dice. • Prompt a user to enter the number of times they would like to roll the dice. • Allow the user to keep rolling the dice until they press '99'. Each prompt must be a separate method. Displaying the results must be a separate method. . .