• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

multiply binomials

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have any advice about multiplying a binomial with the foil method in java?

Like if I needed to multiply (x - 0) (x-1)

How would i represent the x's and then the numbers to generate a polynomial?
 
lowercase baba
Posts: 12796
51
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to do a couple of things...you need to break the expression into tokens, you need to be able to parse each token, you need to know which tokens need to be multiplied by which (i.e. in the expression above, the first 'x' needs to be multiplied by 'x' and '1', but not '0'), and you need to add/combine appropriate tokens (i.e. a 2x and a 3x to get a 5x).

I've probably missed a few things, but this is where I'd start. Once you get some of these parts done, you can start assembling it into your final program.
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!