Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program is done i only need to fix the output, PLEASE PAY ATTENTION TO THE

ID: 3829447 • Letter: T

Question

This program is done i only need to fix the output, PLEASE PAY ATTENTION TO THE CODE. This program add and subtracts polynomials in different ways. The first is with arrays with exponents as an index. the 2nd is with linked list and the last is with sorting. The problem lies in the output specifically the 2nd test(sorting array of terms) and the fourth test(linked list of terms in array), Here is my problem instead of printing out the polynmials i get nulls and other weird outputs. It seems that problem lies in the Array sorted class and LinkedListInArray class. I am going to give all the code and output for context. Please check them

Here is the polynomial interface:

Here is the Array with index(works fine)

Here is array sorted( here is what i need to fix):

Here is the LinkedListInArray( the 2nd place i need to change):

The demo class:

My output(pay attention to the fourth and 2nd test)

Explanation / Answer

PLease notice the ArraySortedPolynomial class as per your code:

public class ArraySortedPolynomial implements PolynomialInterface {
   ArraySortedPolynomial() {
   }

   ArraySortedPolynomial(String pol) {
   }

   @Override
   public PolynomialInterface add(PolynomialInterface other) {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public PolynomialInterface subtract(PolynomialInterface other) {
       // TODO Auto-generated method stub
       return null;
   }

}


There is no toString() method defined, as defined in the class ArrayWithExponentAsIndexPolynomial class. Hence When you try to print the object through system.out.println, you get this strange looking characters( ArraySortedPolynomial@139a55), which is nothing but the hexadecimal address of the object.

Similarly look at the add and subtract method above, they are returning null.. Hence your print statements are giving nulls.. You need to implement both the classes ArraySortedPolynomial.java and LinkedListInArrayPolynomial.java in order to get the code working.. If you would have given the details of how they would be imlemented, i might have helped you in implementing.. As you asked the reason, i have explained that.. Please correct your code in whatever way you want to implement the classes and implement toString method.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote