Search:

Type: Posts; User: Elyril

Search: Search took 0.53 seconds.

  1. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    Yes, I hope so too. I should also take it slow and think. Thank you again
  2. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    Thank you so much! I feel like my head was going to explode...
  3. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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...
  4. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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() *...
  5. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and 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 + " ");
    ...
  6. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and 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 + " ");
    }

    output:
  7. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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...
  8. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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.
  9. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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 =...
  10. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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...
  11. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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

    ...
  12. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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...
  13. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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() *...
  14. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and 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...
  15. Replies
    30
    Views
    2,219

    [SOLVED] Re: Counting and Math.random

    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.
  16. Replies
    30
    Views
    2,219

    [SOLVED] Counting and Math.random

    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...
Results 1 to 16 of 16