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

Thread: Need Hlp with my prg.

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need Hlp with my prg.

    Hello this is my Question in queue using array...



    .................................................. ...........................

    the task is to create a queue application using array. Include the methods given below:

    _depth(Object) -to print the elements that appear before the given element in queue
    (including the same element)

    For Example, the following is the queue.
    5 2 56 12 4 21

    if the given element is 12, the output should be:
    5 2 56 12
    IF the given element is 78, the output should be:
    No element before 78

    write the test class to these method.

    .................................................. .................................................



    Plzz replay as soon as possible and Thanx in advance
    Last edited by Faha; January 10th, 2011 at 04:35 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Need Hlp with my prg.

    For future reference, please use the [highlight=java][/highlight] tags, I have edited your post above for you.

    What have you tried for the method depth? Think about the steps necessary to accomplish what is asked and break the problem down. Do you need to step through the queue? What sort of loop is necessary for this?

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need Hlp with my prg.

    thanx 4 the edit..

    that what i did but still there is missing thing

    public Object printDepth(int a)
    {
    if(!isEmpty())
    {
    for(int i=front;i!=rear+1;i++)

    System.out.println(a.value+queue[i]);
    }
    else
    System.out.println("its Empty queue");
    }
    }

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Need Hlp with my prg.

    I will reiterate the use of using the tags I mentioned in my previous post, as not always will there be someone able to edit the post, and doing so will help you receive help much sooner.

    that what i did but still there is missing thing
    Missing what? What do you expect from what input, and what do you get?

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need Hlp with my prg.

    For Example, the following is the queue.
    5 2 56 12 4 21

    if the given element is 12, the output should be:
    5 2 56 12
    IF the given element is 78, the output should be:
    No element before 78

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Need Hlp with my prg.

    I understand the question (which you just reiterated from your first post)...what I am asking is how your code behaves. You posted a printDepth method above...but what is wrong with it? How does it misbehave? Recommended reading How to ask questions

Tags for this Thread