import java.util.Random;
import java.util.Scanner;
public class DieClass
{
public static void main(String []args)
{
Random gen = new Random();
Scanner reader = new Scanner(System.in);
System.out.println("How many times do you want to roll?");
int rollamt = reader.nextInt();
int arraySum [] = new int [13];
for (int i = 0; i < rollamt; i++)
{
int [] arrayDice = new int [rollamt];
int dice1 = gen.nextInt(6) + 1;
int dice2 = gen.nextInt(6) + 1;
int total = dice1 + dice2;
arrayDice[i] = total;
arraySum[total]++;
}
for (int x = 0; x < 13; x++)
{
double percent = arraySum[x] / rollamt * 100;
System.out.println("Number " + x + " was rolled "
+ arraySum[x] + " times. Percentage is " + percent + "%");
}
}
}
I think there is a logic error here. When I run it the percentage is always 0%. why is that? (int percent specifically)
By obtaining the value in my arraySum array I simple divide it by the amount of rolls and multiply it by 100.