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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

You need prints the coefficient followed by "x^" and appended by the exponent. But with the following additional rules: o if the coefficient is 1, then it is not printed. o if the exponent is 1, then it is not printed ( the caret is not printed as Output Expected 4x^4 Output well). 

 

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 O, 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.
O Test Case 2
Input
Your
Output
Expected
Output
Input
Your
Output
45 0
23
O Test Case 3
Expected
Output
No Output
90x^3
19
51
No Output
5x110
O Test Case 1
Input
Your
Output
Expected
Output
11
43
No Output
4x^4
O Test Case 2
O Test Case 3
Transcribed Image Text: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 O, 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. O Test Case 2 Input Your Output Expected Output Input Your Output 45 0 23 O Test Case 3 Expected Output No Output 90x^3 19 51 No Output 5x110 O Test Case 1 Input Your Output Expected Output 11 43 No Output 4x^4 O Test Case 2 O Test Case 3
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education