Yes, I hope so too. I should also take it slow and think. Thank you again
Type: Posts; User: Elyril
Yes, I hope so too. I should also take it slow and think. Thank you again
Thank you so much! I feel like my head was going to explode...
System.out.println("\n Random: " + java.util.Arrays.toString(counts));
and the result being
1 8 7 7 3 1 5 4 8 3 8 2 9 6 5 4 0 3 7 1
Random: [1, 3, 1, 3, 2, 2, 1, 3, 3, 1]
Is the print...
So like this? Since I can't control what numbers show up?
//array
int[] counts = new int[10];
//random number loop
for(int r = 0; r < 20; r++) {
int randNum = (int)(Math.random() *...
//array
int[] counts = new int[10];
//random number loop
for(int r = 0; r < 20; r++) {
int randNum = (int)(Math.random() * 10);
System.out.print(randNum + " ");
...
//array
int[] counts = new int[10];
//random number loop
for(int r = 0; r < 20; r++) {
int randNum = (int)(Math.random() * 10);
System.out.print(randNum + " ");
}
output:
Yep, not sure if this is totally what you meant, but this is what I got from it. I tried to print it by putting System.out.println(counts); but that only gave me '[I@1b845568' and I have no idea what...
The assignment asks that for the program to count the number of times each distinct numbers occurs. So, it wants to show how many 0s, how many 1s, etc.
So, do you mean to put another loop inside of the first loop? or put it all in one loop? Sorry I don't really get this.. This is what I put.
int[] digitArray = new int[101];
int[] counts =...
Okay, so I have no idea what you mean by that to be honest. This is what I have written down.
for (arrayCount = 1; arrayCount < digitArray.length; arrayCount++) {
System.out.print(arrayCount...
Sorry, I don't think I'm understanding well enough. Although I tried to increment each element, it's just the same number for all of them which is what happened before. This was my code
...
Oh, I figured out what you were saying now. Thanks! But now, I'm confused about the counting each integer from that one array.. Some people say to make an array of 10 (0-9) integers then count them...
I fix the index problem, but for the random numbers, I have to use the Math.random(); so I'm confused on getting that to work properly. because I have the
int numbers = (int)(Math.random() *...
Okay, so I put this in the array loop, not sure if it matters, but now the numbers change, so instead of 0 it would be 3 or 7, but they're all that same number.
for (arrayCount = 1; arrayCount...
how would I do that exactly with 100 different arrays? The programs I've seen only do something like
array[0] = 0
array[1] = 2
array[2] = 5
//etc.
Hey, so I need some major help with this problem.. maybe not major, but I'm trying to generate random 100 numbers, from 0 to 9, in an array using Math.random, but it only outputs 0s which is very...