3 次関数電卓を使用して、次数を使用できるようにしたいと思います。そのためにコードをどのように変更しますか?
c.println("Welcome to this program which will help you solve a cubic function"); //top text
c.println ("");
c.println("Please enter coefficients in the following form"); //explaining the format
c.println("f(x) = ax^3 + bx^2 + cx + d");
c.print(" Enter your X value: "); //asking for the x value
double x = c.readDouble();
c.print("Enter your first coefficient (a): "); //asking for the x value
double a = c.readDouble();
c.print("Enter your second coefficient (b): "); //asking for the x value
double b = c.readDouble();
c.print("Enter your third coefficient (c): "); //asking for the x value
double c1 = c.readDouble();
c.print("Enter your last coefficient (d): "); //asking for the x value
double d = c.readDouble();
c.println(CubicFunction(x,a,b,c1,d),0,2); //prints out the final result, rounded to 2 decimals
c.println ("");
int choice = 1; // initializes choice to 1 so it can enter the main loop
while (done == false) //main loop