Develop a Java program that can be used to add polynomials. In general, a polynomial is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Develop a Java program that can be used to add polynomials. In general, a polynomial is an algebraic expression of the form: P(x) = aoxn-1 + a₁xn-2 + a₂xn-3 + ... + an-2x¹ + an-1 E (1) = To + T + T, + ... + Tn-z + Tn-i Each term of the polynomial, T₁ = a₁xn-(i+1), has a coefficient a; and an exponent n - (i+1). The expression for P(x) doesn't have to include all terms, To, T₁,..., Tn-1 as some coefficients might be zero. Therefore, one needs to keep track of the non-zero coefficients. It is suggested that your program defines a class, say, polynomial, as well as methods to process objects of that class. The coefficients and exponents of terms (along with the number of non-zero terms) are to be maintained for polynomial object instance. Methods of the class should allow the user to carry out at least the following: Initialize a polynomial. A new polynomial starts with no terms. (Hence, the number of terms in it is zero.) Append a new term to a polynomial object. Each term is specified by a coefficient and an exponent for x. Appending a term to a polynomial increases the number of terms in it by 1. Input a polynomial. Such a method allows the user to enter the number of terms, and the coefficients and exponents of all terms. (The method to input a polynomial might make use of the method that appends a term to a polynomial.) Add two polynomials. Given two polynomials, it computes their sum. Display a polynomial. This allows the user to display the non-zero terms of a polynomial in the form given by (1). Submit a brief report that includes a listing of your program and results of several test runs. A run test prompts the user to enter two polynomials P₁, P2, computes their sum, P3 = P₁+ P₂, and displays all three polynomials, P₁, P2 and P3. Assume that the highest degree of a polynomial is a constant MAX_DEG (e.g., 10). You should insert sufficient comments in your code to make it self-explanatory. If necessary, include pseudo-code that explains the underlying algorithms used in developing the program. Reading such code might be read at the discretion of the grader. Develop a Java program that can be used to add polynomials. In general, a polynomial is an algebraic expression of the form: P(x) = aoxn-1 + a₁xn-2 + a₂xn-3 + ... + an-2x¹ + an-1 E (1) = To + T + T, + ... + Tn-z + Tn-i Each term of the polynomial, T₁ = a₁xn-(i+1), has a coefficient a; and an exponent n - (i+1). The expression for P(x) doesn't have to include all terms, To, T₁,..., Tn-1 as some coefficients might be zero. Therefore, one needs to keep track of the non-zero coefficients. It is suggested that your program defines a class, say, polynomial, as well as methods to process objects of that class. The coefficients and exponents of terms (along with the number of non-zero terms) are to be maintained for polynomial object instance. Methods of the class should allow the user to carry out at least the following: Initialize a polynomial. A new polynomial starts with no terms. (Hence, the number of terms in it is zero.) Append a new term to a polynomial object. Each term is specified by a coefficient and an exponent for x. Appending a term to a polynomial increases the number of terms in it by 1. Input a polynomial. Such a method allows the user to enter the number of terms, and the coefficients and exponents of all terms. (The method to input a polynomial might make use of the method that appends a term to a polynomial.) Add two polynomials. Given two polynomials, it computes their sum. Display a polynomial. This allows the user to display the non-zero terms of a polynomial in the form given by (1). Submit a brief report that includes a listing of your program and results of several test runs. A run test prompts the user to enter two polynomials P₁, P2, computes their sum, P3 = P₁+ P₂, and displays all three polynomials, P₁, P2 and P3. Assume that the highest degree of a polynomial is a constant MAX_DEG (e.g., 10). You should insert sufficient comments in your code to make it self-explanatory. If necessary, include pseudo-code that explains the underlying algorithms used in developing the program. Reading such code might be read at the discretion of the grader.
Expert Answer:
Answer rating: 100% (QA)
Below is an example Java program that implements a polynomial class with the specified functionalities java import javautilScanner class Polynomial pr... View the full answer
Related Book For
Statistics For Business Decision Making And Analysis
ISBN: 9780321890269
2nd Edition
Authors: Robert Stine, Dean Foster
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
Calculate the CGT payable in relation to each of the following disposals, assuming in each case that the annual exemption is fully utilised against other gains, that there are no allowable losses and...
-
Olesen, Butterworth, Leach, Kelaher, and Pirkis (2013) selected a sample of 8,315 respondents from a population of about 22 million people who live in Australia to study the effects of mental health...
-
Find the derivative. Assume that a, b, c, and k are constants. f(x) = x + 3 x
-
In 1970, Rose Mary Knick purchased 90 acres of land in Scott Township, Lackawanna County, Pennsylvania. In 2008, another resident of Scott Township discovered documents that suggested that one of...
-
The following items were selected from among the transactions completed by Isis Co. during the current year: Feb 15. Purchased merchandise on account from Viper Co., $260,000, terms n/30. Mar. 17....
-
Give an Example NoSQL and describes is history and evolution in relation to databases?
-
Snow shows the following accounting records: P3,000,000 Net Sales for 2023 Cost of goods sold for 2023 1,800,000 Inventories, 12/31/2022 553,000 inventories, 12/31/2023 462,000 Assuming there are 315...
-
The chart below contains a description of top risks, inherent risk assessment, three risk response alternatives, and residual risk assessment for each response alternative for Jones Hiking Trails....
-
BUS 420 - Capital Structure - page 3 Team # 2. World Outsourcing Corp. (WOC) is an unleveraged firm with 60m shares outstanding. WOC's marginal income tax rate is 40% per year; its financial distress...
-
1) Evaluate the company's marketing profitability and how it contributes to net profit before taxes. 2) How would marketing profits and net profit change if sales increase by 25 percent? 3) Evaluate...
-
Deus Inc. manufactures office tables and chairs in its two factories located in Luzon and Visayas. Both factories produce the same two products and then sells them to wholesalers located in the...
-
On December 31, Year 1, Delta issues 1 million shares of common stock to equity investors in exchange for $50 million in cash. Delta traditionally declares and pays an annual dividend of $2 per share...
-
A small bakery produces two types of cakes: plum cake and chocolate cake. He sells plum cake for $0.69each and chocolate cake for S0.27each. If his total revenue from a day's production is $12.18,...
-
Describe the general ways that the revised Form 990, applicable for tax year 2008 and beyond, is different from previous versions.
-
The following correlation matrix shows the pairwise correlations among three variables. The variables are the expert ratings assigned to wines by well-known connoisseurs (from 0 to 100), the year of...
-
1. A forecast is the prediction of a future value of a time series. 2. The approximate prediction interval 2se works well for forecasts from a polynomial trend model particularly when extrapolating...
-
A contractor built 30 similar homes in a suburban development. The homes have comparable size and amenities, but each has been sold with features that customize the appearance, landscape, and...
-
Lana Priest set up a home sewing business on 1 July 2019. Usually, Lana collects $20 per hour for sewing on the completion of each days work and pays for the maintenance of her machine with cash....
-
Craigs Car Detailing Service had the following accounts and account balances in the adjusted trial balance columns of its worksheet for the year ended 30 June 2019. Required (a) Record the required...
-
The accounts below are taken from the ledger of Bartel Music Consulting on 30 June 2019, the end of the current financial year. Required (a) Record the closing entries that affected the accounts. (b)...
Study smarter with the SolutionInn App