JAVA CODE PLEASE 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. 1·1 4·3 Output Display the resulting product for each of the test case. 4x^4

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

JAVA CODE PLEASE

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.

1·1 4·3

Output

Display the resulting product for each of the test case.

4x^4
3. Term
E Run Tests
by CodeChum Admin
1
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'.
O Test Case 1
Input
11
There should be two operations for the Term:
4 3
• public Term times (Term t) - multiplies the term with another term and
returns the result
Your
No Output
• public String tostring() - 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)
o if the exponent is 0, then only the coefficient is printed.
O Test Case 2
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 3
Test Case 2
Input
45 0
2 3
Your
No Output
Output
Expected
90x^3
Output
O Test Case 3
Input
19
5 1
Your
No Output
Output
Expected
Output
5x^10
Transcribed Image Text:3. Term E Run Tests by CodeChum Admin 1 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'. O Test Case 1 Input 11 There should be two operations for the Term: 4 3 • public Term times (Term t) - multiplies the term with another term and returns the result Your No Output • public String tostring() - 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) o if the exponent is 0, then only the coefficient is printed. O Test Case 2 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 3 Test Case 2 Input 45 0 2 3 Your No Output Output Expected 90x^3 Output O Test Case 3 Input 19 5 1 Your No Output Output Expected Output 5x^10
Expert Solution
steps

Step by step

Solved in 2 steps with 1 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