import javax.swing.*; public class PolyTestMain { public static void main(String[] args) { String text; Polynomial p0= new Polynomial(); Polynomial p1= new Polynomial(); // Read in polynomial 0 System.out.println("Polynomial 0"); do { text= JOptionPane.showInputDialog("Enter polynomial 0 term degree (-99 to end): "); int d= Integer.parseInt(text); if (d == -99) break; text= JOptionPane.showInputDialog("Enter polynomial 0 term coefficient: "); double c= Double.parseDouble(text); // Add term to your polynomial // Print the polynomial here as each term is added } while (true); // Read in polynomial 1 System.out.println("Polynomial 1"); do { text= JOptionPane.showInputDialog("Enter polynomial 1 term degree (-99 to end): "); int d= Integer.parseInt(text); if (d == -99) break; text= JOptionPane.showInputDialog("Enter polynomial 1 term coefficient: "); double c= Double.parseDouble(text); // Add term to your polynomial // Print the polynomial here as each term is added } while (true); do { text= JOptionPane.showInputDialog("Action:A)dd,S)calar mult,M)ult,E)val,D)eriv,Q)uit:"); if (text.equals("A") || text.equals("a")) { System.out.println("Add:"); // Add polynomial1 to polynomial0 // Print the resulting polynomial0 } else if (text.equals("S") || text.equals("s")) { String text1= JOptionPane.showInputDialog("Enter scalar multiplier: "); double z= Double.parseDouble(text1); System.out.println("Scalar multiply by " + z); // Scalar multiply both of your polynomials by z // Print the resulting polynomials } else if (text.equals("M") || text.equals("m")) { System.out.println("Multiply:"); // Multiply your two polynomials // Print the resulting polynomial } else if (text.equals("E") || text.equals("e")) { String text2= JOptionPane.showInputDialog("Enter x: "); double x= Double.parseDouble(text2); System.out.println("Evaluate at x= " + x); // Evaluate both polynomials // Print the polynomials and the result } else if (text.equals("D") || text.equals("d")) { System.out.println("Derivative"); // Find the derivative of both polynomials // Print both resulting polynomials } else break; } while (true); System.out.println("Done"); System.exit(0); } }