Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Array - Random Numbers Progra, Help

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Array - Random Numbers Progra, Help

    Hello everyone! I'm new here and started computer programming in September 2010 at my high school.

    Ok, so in class we receive program lists that contain instructions for programs our teacher wants us to make. And so I need help with one that requires me to read 30 random numbers and reads out the mean and mode, by using arrays (which I still dont complete understand). Please forgive me for my vast ignorance; I feel my computer science is extremely lax and has not adequately taught us over the months about what we should know by now.

    Well here's the program(how do I format again?):
    import java.util.Random;
     
    public class TestScores 
    {
    public static void main (String [] args)
     
    {
     
    int scores=0;
     
    int avg;
     
    int mean;
     
    int mode;
     
    final int LIMIT = 15, MULTIPLE = 100;
     
    int[]list = new int [LIMIT];
     
        Random generator = new Random();
     
    //Initialize the array values 
     
      for (int score = 0; score < LIMIT; score++)
     
      {list [score] = generator.nextInt(30);
     
      scores += list[score];
     
      }
     
      avg = scores/30;
     
      //Print the array values
     
      for (int value : list)
     
      System.out.print ( + " ");
     
     
       }
     
    }
    Last edited by helloworld922; March 21st, 2011 at 10:12 PM.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Array - Random Numbers Progra, Help

    OK, so what is your question?

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Array - Random Numbers Progra, Help

    ^^ my thoughts exactly.

    To format your code, see the links in my signature (either BB code tags, or the official forum rules).

Similar Threads

  1. Can't get seven random numbers, only one.
    By alpvii in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 6th, 2010, 05:39 PM
  2. random numbers in array please help
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 15th, 2010, 01:54 AM
  3. Generating random numbers
    By abelned in forum Object Oriented Programming
    Replies: 1
    Last Post: September 1st, 2010, 07:24 AM
  4. help me .. about creating random numbers
    By soldier in forum Java Theory & Questions
    Replies: 2
    Last Post: December 20th, 2009, 08:24 PM
  5. Random numbers
    By Pooja Deshpande in forum Java SE APIs
    Replies: 8
    Last Post: June 5th, 2009, 04:36 AM