Question: 3. Term by CodeChum Admin JAVA CODE Construct a class called Term. It is going to represent a term in polynomial expression. It has an

3. Term

by CodeChum Admin JAVA CODE

Construct a class called Term. It is going to represent a term in polynomial expression. It has an integer coefficient and an exponent. In this case, there is only 1 independent variable that is 'x'.

There should be two operations for the Term:

  • public Term times(Term t) - multiplies the term with another term and returns the result
  • public String toString() - prints the coefficient followed by "x^" and appended by the exponent. But with the following additional rules:
    • if the coefficient is 1, then it is not printed.
    • if the exponent is 1, then it is not printed ( the caret is not printed as well)
    • if the exponent is 0, then only the coefficient is printed.

Input

The first line contains the coefficient and the exponent of the first term. The second line contains the coefficient and the exponent of the second term.

 

11

43

Output

Display the resulting product for each of the test case.

 

4x^4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!