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

Thread: needs help in java programming.

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

    Default needs help in java programming.

    1. Give a segment of code that will find the position, posLastZero,
    of the last zero element among a[0], a[1], ..., a[n-1]. That is,
    posLastZero should be the largest integer such that
    a[posLastZero] is equal to zero. The value of n is given. If
    there is no zero element among a[0], a[1], ..., a[n-1], the code
    should set posLastZero equal to a negative one.

    Example: n = 7 a[0] = 5
    a[1] = 0
    a[2] = 7
    a[3] = 0
    a[4] = 3
    a[5] = 0
    a[6] = 9

    The code should leave posLastZero equal to 5 in this case, because
    a[5] is the last zero element among a[0], a[1], ..., a[n-1].
    This is only an example; your code must handle any case.





    2. Copy the elements a[0], a[1], ..., a[n-1] into the array b[], but
    rescale them by dividing them by a[0]. For example, if n=4,
    a[0]=1.5, a[1]=9.0, a[2]=3.0, and a[3]=6.0 before the code is
    executed, then afterwards the values of the elements of b()
    should be b[0]=1.0, b[1]=6.0, b[2]=2.0, and b[3]=4.0.
    Each element has been divided by the value, 1.5, of a[0].
    This is only an example; of course your code must be general
    and must handle any number of elements.




    3. Given nA and a[0], a[1], ..., a[nA - 1], with the elements a[j] in
    nondecreasing order (a[0] <= a[1] <= ... <= a[nA-1]), give a segment
    of code that will "squeeze out the duplicates in-place" and
    will set nA equal to the number of unique elements in a.
    That is, if nA=5, a[0]=0.0, a[1]=0.0, a[2]=1.2, a[3]=2.3, and a[4]=2.3,
    then after execution of the code the contents should be a[0]=0.0,
    a[1]=1.2, and a[2]=2.3, and nA=3. The duplicate elements (the second
    value of 0.0 and the second value of 2.3) have been eliminated from
    the array.
    Note:
    (The final contents of a[3] and a[4] can be anything.)
    This is only an example. Your code must be general and must not
    contain any "magic numbers".






    4. How should you declare your instance variables in a class?






    5. Write a constructor for a class named Dog that has instance variables of
    String name, String breed, and int age.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: needs help in java programming.

    What questions do you have about your assignment?
    Post your code with your questions.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: needs help in java programming.

    Quote Originally Posted by ryano View Post
    needs help in java programming.
    When I read this, I can't help but think, "it puts the lotion on its skin, or else it gets the hose..." Useful titles not only help you get help, but they also help us keep from thinking about creepy movies.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Member Emperor_Xyn's Avatar
    Join Date
    Dec 2011
    Posts
    66
    My Mood
    Devilish
    Thanks
    21
    Thanked 2 Times in 2 Posts

    Default Re: needs help in java programming.

    Yeah, I always hate the times I forget what kind of forums i'm on. But luckily the poster reminded me.


    People must really think people will do their homework assignments for them... At least make a little effort...

  5. The Following User Says Thank You to Emperor_Xyn For This Useful Post:

    syntax (December 16th, 2011)

Similar Threads

  1. hi everyone!! I'm new to java programming.. can you help me out? please
    By lyndonbroz in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 11th, 2011, 09:19 AM
  2. [SOLVED] java programming help!!
    By evildarklord99 in forum Java Networking
    Replies: 3
    Last Post: August 23rd, 2011, 08:45 AM
  3. Is java a power full programming language? can java do this?
    By Jhovarie in forum Java Theory & Questions
    Replies: 5
    Last Post: March 2nd, 2011, 02:02 PM
  4. Java programming help
    By Cool_tine in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2011, 11:05 PM
  5. Towards java programming...
    By emigrant in forum Member Introductions
    Replies: 1
    Last Post: February 15th, 2010, 03:17 AM