• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stuck at polynomial program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am stuck at making a rational polynomial program. I have made a class to handle Rational numbers but at the second problem it asks to make a program for RationalPolynomials and I don't know how to start this. I don't understand the arrays much.

Here I have my rational class: http://files.webhop.biz/Rational.txt

And here the problem 2, its long so I make it an image: http://files.webhop.biz/RP_P2.jpg

Can someone help me how to make this? I have to turn it in soon. Thanks for any help.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
People here are not going to do your hoemwork for you. If you have specific questions, describe what you have done so far, and where you're stuck, and we'll help you get going.
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


it asks to make a program for RationalPolynomials and I don't know how to start this. I don't understand the arrays much.



Seems like you are planning to use arrays to store each element in a polynomial.

Each Element have a Rational number as coeffecient, A variable x and an exponent. You need to have a class to represent each element. Call the class 'Element'. Then an array (or collection) of Elements represent your rational polynomial.

If ordering of elements is important, You may use an array or an implementation of OrderedList. Another idea is to extend HashMap and use exponent as key(key need to be non-primitive type).

Below is how you declare a single dimension array.



To initialize the array you need to know the size(number of elemts needed). You can obtain the 'polynomialSize' by counting the '+' (or '-').



Now the array can be initialized by



Now asigning values to polynomial....
In a loop construct each 'Element'. use i as index.



You can refrence the polynomial elements as below.



You have the basics of Array by now.
 
Tso Yee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again. I didn't asked to do the homework for me, I just asked for help to get started with it cause I didn't understand entirely. Thanks jiju for the reply. It helps me a lot.
 
It runs on an internal combustion engine. This ad does not:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic