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.
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
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).

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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 5 images

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education