public class MaxFinder {

public static double FindMaxValue(double a, double b) {
    double y, large = -10000.0;
     for (double j=a; j <= b + .00001; j = j + .01) {
       y = (2.0 * Math.pow(j,4)) + 1.0 * Math.pow(j,3) - 3.0 * Math.pow(j,2);
        if (y > large) large = y;
        }
        return large;
        }


public static void main(String[] args) {
double x1, x2, maxvalue;

            System.out.println("This program will find the maximum value of a function in an interval.");
            System.out.println("The function is 2x^4 + x^3 - 3x^2.");
            System.out.println("The interval extends from x1 to x2, inclusive.");

            System.out.print("Enter the value of x1: ");
            x1 = Keyboard.readDouble();
            System.out.print("Enter the value of x2: ");
            x2 = Keyboard.readDouble();

            maxvalue = FindMaxValue(x1, x2);
            System.out.println("Max value is " + Math.round(maxvalue*100.0)/100.0);
            }
        }


