by CodeChum Admin (JAVA CODE) 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

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

Term

by CodeChum Admin (JAVA CODE)

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
result
Main.java
Java
Custom Input
Output
Test Cases
• 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.
• if the exponent is 1, then it is not printed ( the caret is not printed as well)
o if the exponent is 0, then only the coefficient is printed.
Enter custom input here
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.
11
43
Output
Display the resulting product for each of the test case.
4x^4
Score: 0/10
= Overview
3/3
Execute Code (F10]
Submit Code
Transcribed Image Text:result Main.java Java Custom Input Output Test Cases • 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. • if the exponent is 1, then it is not printed ( the caret is not printed as well) o if the exponent is 0, then only the coefficient is printed. Enter custom input here 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. 11 43 Output Display the resulting product for each of the test case. 4x^4 Score: 0/10 = Overview 3/3 Execute Code (F10] Submit Code
Main.java
Java
Custom Input
Output
Test Cases
3. Term
by CodeChum Admin
Enter custom input here
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:
o 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)
o 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.
Score: 0/10
E Overview
3/3
Execute Code (F10)
Submit Code
Transcribed Image Text:Main.java Java Custom Input Output Test Cases 3. Term by CodeChum Admin Enter custom input here 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: o 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) o 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. Score: 0/10 E Overview 3/3 Execute Code (F10) Submit Code
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Array
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