Design a program that does some polynomial operations

Assignment Help JAVA Programming
Reference no: EM13709828

Linked lists are a convenient way to represent polynomials. Your task is to design a program that does some polynomial operations using a linked list.

A polynomial of degree ?? is defined as,

a0xm+ a1xm-1+...+ am-1x1+am

The degree ?? is the largest exponent in any of the terms of the polynomial. For example, the largest exponent in 4x2-7x+3 is 2.

It is customary to write the term with the largest exponent first, followed by the term with the next largest exponent and so on.

ais are the coefficients of the polynomial. One example of a polynomial of degree 6 is

2x6+x3+5x+4

in which the first term's coefficient is a0=2 and its power is 6; the second term's coefficient is a1=1 and its power is 3.

Tasks are detailed as follows

- You are required to develop your own class to represent polynomials as a linked list. The first node in the list represents the first term in the polynomial, the second node represents the second term, and so forth.

- Each node contains three fields. The first field is the term's coefficient. The second field is the term's power, and the third field is a pointer to the next term.

- The following examples show how a polynomial is represented as a linked list.

5x4+6x3+7

2x3-7x2+3x

Notice that in the linked list:

1. The list has as many nodes as there are terms in the polynomial.

2. Each node in the linked list contains a value for the coefficient, a value for the exponent and a reference.

3. The nodes in the linked list are ordered. Nodes with a higher exponent precede nodes with a lower exponent.

4. The constant term has an exponent of 0.

5. The reference of the last node is NULL.

What to Implement (Task):

- You should have at least two constructor for polynomials. One is used to build a polynomial (linked list) from a file and the other from keyboard input (pairs of coefficients and powers) by a user.

- Implement polynomial addition by using an add() method, so you could write in program :

PolynomialThree= PolynomialOne.add(PolynomialTwo);

The rules for the addition of polynomials are as follows:

1. If the powers are equal, the coefficients are algebraically added.

2. If the powers are unequal, the term with the higher power is inserted in the new polynomial.

3. If the exponent is 0, it represents x0, which is 1. The value of the term is therefore the value of the coefficient.

4. If the result of adding the coefficients results in 0, the term is dropped (0 times anything is 0).

For example, the polynomial sum (27x3+15x2+12x)+(18x2+10x+8) is calculated as

27x3 + 33x2 + 22x + 8

- Get the value of a polynomial given an input. For instance, given x=2, the value of the  polynomial x2+ 3x + 2 is 12 .

- Implement the product of a polynomial by another polynomial which is the algebraic sum of the products of one polynomial by all the monomials of another polynomial.

- Implement the derivative operation for a polynomial. Note that for a monomial axk, its derivative is kaxk -1and the derivative of a constant is 0 and the derivative of a polynomial is equal to the sum of derivatives of its all monomials.

- Implement a InsertTerm() method. This method should put the input term into a polynomial.

- Test your program with the following two polynomials

12x9+5x6+13x5-4x4+2x3 + 11x2 - 6

7x9+2x8+5x6+2x5+2x3 + 9x2 - 7x

- Write a driver program to test all the functionalities that you have defined Rationale

This assessment is designed to:

1. test students' ability in programming with Java

2. Practice their knowledge in fundamental data structures

Reference no: EM13709828

Questions Cloud

Find the electric field magnitude and energy density : A cylindrical capacitor consists of a long wire of radius R1 and length L with a charge +Q and a concentric outer cylindrical shell of radius R2, length L and charge -Q. Find the electric field magnitude and energy density everywhere
Big changes for a small hospital : Read the case and answer the questions at the end of the case. However, answering these questions is not enough. Consider the questions to be clues to the important concepts and facts. Discuss the case in a larger context. Use the following que..
Select a u. s. company with global operations : Select a U. S. company with global operations. Write a 6 page paper in which you will respond to the following: 1. Discuss the firm's activities outside the U.S.  2. Identify which economic concepts, such as comparative advantage, apply to your firm..
What is his position : A pedestrian walking with constant speed is at 5 s at x1 = 13 m and at 11 s at x2 = 18m. What is his position at 7.5 s
Design a program that does some polynomial operations : Implement polynomial addition by using an add() method, so you could write in program - Build a polynomial (linked list) from a file and the other from keyboard input (pairs of coefficients and powers) by a user.
How much does the energy of the capacitor change : A parallel plate capacitor with plates of area 500 cm2 is charged to a potential difference V and is then disconnected from the voltage source. How much does the energy of the capacitor change due to the movement of the plates
Explain how lincoln''s gettysburg address can be used : Explain how Lincoln's Gettysburg Address can be used to help us understand the principles of public leadership.
Calculate the work that mike does on the mower : Mike is cutting the grass using a human-powered lawn mower. Calculate the work that Mike does on the mower in pushing it 9.1 m across the yard
Gives the qualitative dissertation tips : Qualitative research studies can be particularly time intensive to complete. How can a scholar-practitioner specifically plan to make efficient use of his/her time to stay on track with completing a qualitative dissertation.

Reviews

Write a Review

JAVA Programming Questions & Answers

  One acre of land is equivalent to

One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of square feet in a tract of land with 3.5acres.

  Reimplement the labeledpoint class of exercise

Reimplement the LabeledPoint class of Exercise P9.12 by storing the location in a java.awt.Point object. Your toString method should invoke the toString method of the Point class.

  Ask the user to enter a positive non-zero integer value.

Write a program which aske the user to Enter a positve non-zero integer value. if the value enterd zero or negative print as error message and end the program; otherwise, use the integer to call a method displayPattern(n) which must display the follo..

  Create a temperature sensor simulator

create a temperature sensor simulator. First, display a menu that will ask the user what season to simulate (1) winter (2) spring (3) summer (4) fall or (5) to exit. Once the use selects the season your program should ask the user how many simulation..

  Descriptionyou are to write a program that determines the

descriptionyou are to write a program that determines the day of the week for new years day in the year 3000. to do

  Chat monitoring system

The name of the project is chat monitoring system. in the file you will see the screenshot diagram 2A are my design, i want it to be upgrade, to look professional like the diagram 2B. please java, netbeans and GUI. please can I have only the client s..

  Java program that will prompt the user to input a file

Write a Java program that will prompt the user to input a file (document) in order to count the frequency of each word. This program will display the frequency of each word sorted alphabetically or by frequency (depending on the preference of the use..

  Representing an investment value and interest rate

Write a Java test program, all your code should be in the main method that asks the user for two numbers representing an investment value and interest rate.

  Write a program that converts number from binary to decimal

write a program that Converts a Number from Binary to Decimal  by using reading keyboard input.

  Write java method which fills the array with random numbers

Write a Java method which takes an integer array parameter and fills the array with random numbers between 1 and 1000, including 1 and 1000.

  Write a java program that uses a search tree of strings

Write a Java program that uses a search tree of strings to sort text lines in alphabetic order. You may choose how you de?ne alphabetic order as long as there is some sense in the de?nition. You may also choose what kind of tree you use.

  Java application that calculates the body mass index

Write a Java application that calculates and displays the body mass index (BMI) for N people

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd