3. Term by CodeChum Admin 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. 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 5x^18 4 1 ▸ CE Run Tests O Test Case 1 Input Your Output Expected Output 11 43 No Output 4x^4 O Test Case 2 O Test Case 3

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

13. Term 1 that is used. 

by CodeChum Admin

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

 

3. Term
by CodeChum Admin
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.
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
5 1
No Output
5x^10
1
+
CE Run Tests
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:3. Term by CodeChum Admin 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. 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 5 1 No Output 5x^10 1 + CE Run Tests 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
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY