
/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

public class Main
{
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        int[] stock = new int[]{1,3,2,8,4,10};
        int fee=2;
        int buySell=0;
        int[][] difference = new int[stock.length][20];
        int count=0;
        int temp=0;
        
        for (int i=0; i<stock.length;i++)
        {
            System.out.println("\nStock being evaluated");
            System.out.println(stock[i]);
            count=0;
            
            for (int j=i+1; j<stock.length;j++)
            {
                
                if (j!=stock.length-1)
                {
                    if (j==i)
                {
                    j++;
                }
                System.out.println("value of j:" + stock[j]);
                
                if (stock[j]>stock[i] && stock[j+1]<stock[j])
                {
                    buySell++;
                    difference[i][count]=stock[j]-stock[i];
                    System.out.println("this is the difference: " + difference[i][count]);
                    count++;
                    k=j+1;
                }
                }
                
                for (int k=j;k<stock.length;k++)   // this same implementation needed in the top loop
            {
                if (k!=stock.length-1)
                {
                     if (k==j)
                {
                    k++;
                }
                System.out.println("value of k:" + stock[k]);
                
                if (stock[k]>stock[j]&& stock[k+1]<stock[k])
                {
                    for (temp=k;temp<stocks.length;temp++)
                    {
                        if (stocks[temp]>stocks[k])
                        {
                            k=temp;
                            buySell++;
                            difference[i][count]=stock[k]-stock[j];
                            count++;
                            
                        }
                        
                    }
                    
                    System.out.println("this is the difference: " + difference[i][count]);
                    
                }
                difference[i][19]=count;   //count is stored to calculate amount of fees
                
            }
            }
        }
        
        System.out.println("At this point is has stored all instances in which there has been a profit");
        //Now need to calculate most efficient route given 2 fee for buying and selling
        
    }
}
}
