0

it involves using a static array to build and hold the coefficients values and evaluate and analyze them as well as to export the results to an external file such as a text file here is what i have so far any help would be appreciated.

```
import java.util.*;
import java.io.*;
public class ia
{
/**
* @param args
*/
public static void main(String[] args) throws IOException
{
int k;
Scanner input = new Scanner(System.in);
while( k != -1 )
{
System.out.println("0. log off");
System.out.println("1. look through all entered functions");
System.out.println("2. export function and choose location") ;
System.out.println("3 add polynomial");
System.out.println("4 edit function");
k =input.nextInt() ;
System.out.println("enter your choice");
switch (k)
{
case 1: //listpolynomial()
break;
case 2: //export()
break;
case 3:
int leading, degree;
System.out.println("enter leading coefitient");
leading= input.nextInt();
degree= input.nextInt();
Polynomial P =new Polynomial(leading,degree);
break;
case 4:
break;
default : logoff();
}
}
}
public static void logoff()
{
Scanner input = new Scanner(System.in);
String dummy;
System.out.println("\nPress <Enter> to continue.");
dummy = input.nextLine();
}
}
```

```
class Polynomial
{
int coef[];
int deg;
public String toString()
{
if (deg == 0) return "" + coef[0];
if (deg == 1) return coef[1] + "x + " + coef[0];
String s = coef[deg] + "x^" + deg;
for (int i = deg-1; i >= 0; i--)
{
if (coef[i] == 0) continue;
else if (coef[i] > 0) s = s + " + " + ( coef[i]);
else if (coef[i] < 0) s = s + " - " + (-coef[i]);
if (i == 1) s = s + "x";
else if (i > 1) s = s + "x^" + i;
}
return s;
}
public Polynomial(int a, int b)
{
coef = new int[b+1];
coef[b] = a;
deg = degree();
}
public Polynomial differentiate()
{
if (deg == 0) return new Polynomial(0, 0);
Polynomial deriv = new Polynomial(0, deg - 1);
deriv.deg = deg - 1;
for (int i = 0; i < deg; i++)
deriv.coef[i] = (i + 1) * coef[i + 1];
return deriv;
}
public int degree()
{
int d = 0;
for (int i = 0; i < coef.length; i++)
if (coef[i] != 0) d = i;
return d;
}
}
```

```
class List
{
private int capacity;
private Polynomial poly [];
private int size
public void export()
{
Scanner put = new Scanner(System.in);
String filepath;
System.out.print("Enter file path ====> ");
filepath=put.nextLine();
File f1 = new File(filepath+"list.txt");
}
public void List(int c)
{
capacity=c;
size=0;
poly=new Polynomial[capacity];
}
public void getlist()throws IOException
{
FileReader inFile = new FileReader(f1);
in = new BufferedReader(inFile);
String s1,s2,s3,s4;
int root, degree,derivative
while( ((s1 = inStream.readLine()) != null) &&
((s2 = inStream.readLine()) != null) &&
((s3 = inStream.readLine()) != null) &&
((s4 = inStream.readLine()) != null) )
{
}
}
}
```

*Edited 4 Years Ago by peter_budo*: Correcting code tags to highlight code