Hey guys, I am writing a program that fills an array of 100 with values from 1 to six( like a dice roll game) Then i have to count the number of times the integer appears. THEN i have to output an asterisk for the amount of time each number occurs. I have everything done up until the asterisk part. I can't figure it out to save my life. heres my code.
I can out put the correct number of asterisks for the first digit. But i need it to be seperate from the rest of it. The point of the asterisks is to make it look like a graph.
This assignment basically determines if i pass the class or not so any help would be greatly appreciated. Thanks in advance!
Code:
public class finalJavaProject
{
public static void main (String[]args)
{
int numOne=0;
int numTwo=0;
int numThree=0;
int numFour=0;
int numFive=0;
int numSix=0;
char asterik ='*';
int[] indRoll = new int[100];
for(int index=0;index<100;index++)
{
indRoll[index]=(int) (Math.random()*6)+1;
if(indRoll[index]==1)
{
numOne++;
System.out.print(asterik);
}
if(indRoll[index]==2)
{
numTwo++;
;
}
if(indRoll[index]==3)
{
numThree++;
}
if(indRoll[index]==4)
{
numFour++;
}
if(indRoll[index]==5)
{
numFive++;
}
if(indRoll[index]==6)
{
numSix++;
}
}
System.out.println();
System.out.println("Number of 1's: "+numOne);
System.out.println("Number of 2's: "+numTwo);
System.out.println("Number of 3's: "+numThree);
System.out.println("Number of 4's: "+numFour);
System.out.println("Number of 5's: "+numFive);
System.out.println("Number of 6's: "+numSix);
System.out.println();
System.out.println();
System.out.println();
System.out.println();
System.out.println();
}//end main
}//end public
I can out put the correct number of asterisks for the first digit. But i need it to be seperate from the rest of it. The point of the asterisks is to make it look like a graph.
This assignment basically determines if i pass the class or not so any help would be greatly appreciated. Thanks in advance!