public static void main(String[] args)throws IOException 
    {        
        double finalAnswer=0;
        double finalcurvePoints=0;
        double finalPeriod=0;
        double finalPercDif=0;
        double finalR2=0;
        
        for(int i = 19;i<=30;i++){
            for(int j=2;j<=10;j++){
                for(int k=8;k<=21;k++){
                    for(int m=0;m<=10;m++){
                        
                        int curvePoints=i;
                        int period=j;
                        double difPercent=(double)k/10;
                        double R2=(double)m/30;
                        
                        double answer=OptimiseParameters(R2,curvePoints,period,difPercent);
                        if(finalAnswer<answer){
                            finalR2=R2;
                            finalAnswer=answer;
                            finalcurvePoints=curvePoints;
                            finalPeriod=period;
                            finalPercDif=difPercent;
                        }
                    }
                }
            }
        }
        System.out.println("The best parameters are : ");
        System.out.println("period : "+finalPeriod);
        System.out.println("curvePoints : "+finalcurvePoints);
        System.out.println("PercentDifferenceNeeded : "+finalPercDif);
        System.out.println("R2 : "+finalR2);
        System.out.println("The best effective annual return for these parameters is : "+finalAnswer);
    }