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 5 of 5

Thread: need help in program creation

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help in program creation

    Suppose there is an integer array holding following elements:
    1,3,4,5,6,3,2,4,6,7,9,4,12,3,4,6,8,9,7,6,43,2,4,7, 7,5,2,1,3,4,6,311,1

    Write a program which prints which each number from array and the times it has been repeated in array
    Fox eg
    1- Repeated 3 times
    4- Repeated 6 times


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    69
    My Mood
    Relaxed
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default Re: need help in program creation

    What is the problem you are having?

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: need help in program creation

    ok im going to explain this with a dice... And btw i have just learned this :) so this is an exercise for me too :)
    becouse i dont know how to upload an java file here cuz i says its invalid or something (please someone explain how to do that >_>"), im gonna write it now becouse it is short :)

    import java.util.Random;
    public class X()
    {
    public static void main(String[] args)
    {
    Random random = new Random ();
    new Array[] = new Int (7); // as it goes from 0 - 6

    for (int a=0; a<1000; a++)
    {
    ++Array[1+ random.nextInt(6);//instead of goin from 0-5, becouse of +1 it will go now from 1-6,
    }

    System.out.println("Nr\tFrequency");\\ the \t is just tab for space

    for (int Nr=1; Nr<Array.length; Nr++);
    {
    System.out.print(Nr+"\t"+Array[Nr]);
    }
    }
    }

    the ++ before Array is to add to the value of the current index - a
    for example: ++Array[4] - add 1 to index 4( that means u roled a 3 ;) ) or u can say also increment


    I hope that I understood what the problem is and if not it was a good exercise :P... Again sorry i dont know how to post java code... :(

    edit* ok i saw now that im kinda late haha... But could someone anyway explain how to post java code?
    Last edited by exens; August 15th, 2012 at 05:59 PM.

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: need help in program creation

    @vinaysa86 - That is considered a homework dump. You have asked no real question, just posted your assignment. This is frowned upon as it is uneducational and considered cheating.

    @exens - That is considered spoonfeeding and is also frowned upon. For your question type [code=java] before your code and [/code] after your code.

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: need help in program creation

    exens, what does that code have to do with the original post? It contains several errors and is not even compilable.

    Please a) read the forum rules b) understand the rules regarding spoonfeeding c) and please understand this is a technical forum - please use proper English grammar (cuz and goin are not words in the english dictionary, and on technical forums can cause confusion)

Similar Threads

  1. Apache XML-RPC server creation problem
    By r0x in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 10th, 2011, 09:52 AM
  2. Looping object creation
    By Charlie in forum Java Theory & Questions
    Replies: 5
    Last Post: June 19th, 2010, 11:12 AM
  3. Component/Widget creation
    By Hellops in forum AWT / Java Swing
    Replies: 0
    Last Post: October 15th, 2009, 10:31 PM
  4. Replies: 2
    Last Post: July 8th, 2009, 06:35 AM
  5. WAR file creation in Eclipse JEE
    By katty in forum Java IDEs
    Replies: 5
    Last Post: May 21st, 2009, 09:45 AM