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: Urgent Polynomial Assignment !!!!!!!!!

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Urgent Polynomial Assignment !!!!!!!!!

    Hey Guys

    I need to create a mini program which adds and subtracts polynomials using only an ArrayList structure !!
    I am really struggling to think of how to start to design this program
    I know that an ArrayList is like array but dynamic and does not have to have a fixed number of elements.
    I was thinking of using the index of the array list as the exponent and storing coefficients in the actual array list but don't really know how to start

    I would really apperciate any suggestions !!!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,357
    My Mood
    Hungover
    Thanks
    144
    Thanked 626 Times in 537 Posts

    Default Re: Urgent Polynomial Assignment !!!!!!!!!

    Recommended reading: Starting Writing a Program
    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!

  3. #3
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Urgent Polynomial Assignment !!!!!!!!!

    Quote Originally Posted by thesoulpatchofBruce View Post
    Hey Guys

    I need to create a mini program which adds and subtracts polynomials....
    Deciding on the data structure for the polynomials is a good way to start.

    Given that you are supposed to use an ArrayList, the only thing to decide is what to put in the ArrayList.

    So, suppose you are given a polynomial of degree n:
    a0 + a1*x + a2*(x to the power 2) + a3 * (x to the power 3) + ... + an * (x to the power n)

    There are n+1 coefficients that define a polynomial of degree n. (Note that if an is equal to zero, its degree is less than n, so that statements assumes that an is not zero).

    One way to handle polynomials is what I think you mean: for an ArrayList, the coefficient of (x to the power k) will be stored in the array list index k for k = 0, 1, ..., n. (That is, a0 would be stored in the zero index position, then a1 would be stored in the index 1 position, etc.)

    (Another way would be to put the coefficient of the highest power first.)

    I like your way better, but there are reasons that some folks do it the otherway round.



    Cheers!

    Z
    Last edited by Zaphod_b; October 9th, 2012 at 01:41 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: Urgent Polynomial Assignment !!!!!!!!!

    Urgent Polynomial Assignment !!!!!!!!!
    Speaking in terms of me getting out of the ocean and skipping across the beach, it does not matter how many '!' you put in the title, or how urgent your assignment is to you, I get out when I get out, and I check the forum when I feel like it. Just like the other people who volunteer their time here.

    On the other hand, speaking in terms of common courtesy, it is not an acceptable practice to do things like all caps the title, or add multiple '!' on the end. Drawing this kind of attention to your post will actually cause many people to complain about your title rather than offering assistance with the question in your post, or ignore the post completely.

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

    KevinWorkman (October 9th, 2012)

Similar Threads

  1. Need Urgent Help for Java assignment..
    By SamanthaBenny93 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: May 22nd, 2012, 08:25 AM
  2. Solving a polynomial
    By arvindbis in forum Java Theory & Questions
    Replies: 9
    Last Post: March 7th, 2012, 11:16 PM
  3. help with array assignment ! urgent please :(
    By dre2327 in forum Collections and Generics
    Replies: 5
    Last Post: October 6th, 2011, 01:30 PM
  4. Need urgent help in assignment of JAVA, any idea suggestion plz
    By aesthete in forum Java Theory & Questions
    Replies: 2
    Last Post: January 6th, 2011, 04:58 AM
  5. nid help for my assignment~urgent
    By x3ahbi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 5th, 2010, 02:55 AM