Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY