
/*
Online Java - IDE, Code Editor, Compiler

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

//so far this has examined all stocks
//it looks at the buying and selling. and keeps track of difference
// need to address why it does not perform checks with last two stocks


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;
        int k;
        
        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]) // this will check all occurences of potential point for sale
                {
                    if (j==1)
                    {
                        difference[i][count]=stock[j]-stock[i];
                        System.out.println("this is the difference1: " + difference[i][count]);
                        count++;
                        continue;
                        //j=stock.length-1;
                    }
                    
                    difference[i][count]=stock[j]-stock[i+1];
                    System.out.println("this is the difference: " + difference[i][count]);
                    count++;
                    
                    for (temp=j+1;temp<stock.length;temp++) // this will check all other occurences if applicable point for sale
                    {
                        if (temp==j+1)
                        {
                            System.out.println("This is the next highest one: " + stock[temp]);
                            difference[i][count]=stock[temp]-stock[j];
                            System.out.println("this is the difference: " + difference[i][count]);
                            difference[i][19]=count; // this will store number of transactions occured total
                            count++;
                            continue;
                        }
                        
                        if (stock[temp]>stock[j] && stock[j+1]<stock[j])
                        {
                            
                            System.out.println("This is the next highest one: " + stock[temp]);
                            difference[i][count]=stock[temp]-stock[j+1];
                            System.out.println("this is the difference: " + difference[i][count]);
                            difference[i][19]=count; // this will store number of transactions occured total
                            count++;
                        }
                        
                        
                    }
                    
                    
                    
                }
                
                
                }
                
                
                
                
        }
        
        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
        
    }
}
}
