
/*
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 :)");
        
        
        
        System.out.println("This will be simple example at moment demonstrating if there is arbitrage");
        System.out.println("To keep it simple, it will compare each currency against only one other currency");
        
        //int [][][] all Conversions = new int[]()
        
        // not sure how to store the integer arrays into a larger container..
        // perhaps create a 3d array... but not worrying at moment.
        
        // this is to verify no arbitrage
       
       // this is the same on horizontal and vertical
       String [] currency = new String[]{"£","$","€"};
       
       //maybe need currency symbol outside of array
       //and then decalre as integer array?
       double currencies [][] =   {
                                 
                                 {1.00,1.25,1.17},
                                 {0.80,1.00,0.94},
                                 {0.85,1.07,1.00},
                                 
                                  };
      
       // since no indication of which currency is which, it will use indexof- at first index of 2d array.
      
      // determine which row to use
      //This is taken to be user inputs from Scanner. To be implemented later
      
      // This will first execute to test a single conversion from one currency to another and back again
      // it will be tested in normal conditions and then in arbitrage
      
      
      // NORMAL CONDITIONS ************************
      
      int count=0;
      ////Object k = null;
      
      String input = "£";
      String output = "$";
      double amount = 3.00;
      int inputRow=0;
      int outputRow=0;
      
      System.out.println(input+amount + " to be converted to " + output);
      
      /*
      for (Object [] o: currencies)
      {
          count++;
          for (Object k: o)
          {
              if (k==input)
              {
                  System.out.println("Detected a: " + input + " on line: " + (count-1));
                  inputRow=count-1;
              }
              
              if (k==output)
              {
                  System.out.println("Detected a: " + output + " on line: " + (count-1));
                  outputRow=(count-1);
                  //row=k;
              }
              
          }
          
      }
      
      
      
      int typeCurrency=0;
      int columnCurrency=0;
      
      
      */
      int column=0;
      int inputCurrency=0;
      int outputCurrency=0;
      
      //String [] currency = new String[]{"£","$","€"};
      
      for (String c: currency)
      {
          if (c==output)
          {
              System.out.println("Detected an: " + output + " in column: " + (column));
              
              outputCurrency=column;
          }
          
          if (c==input)
          {
              System.out.println("Detected an: " + input + " in column: " + (column));
              
              inputCurrency=column;
              
          }
          column++;
    }
    
    System.out.println("CONVERSION**************");
    
    //currency.charAt
    System.out.println("inputRow is: " + inputCurrency);
    System.out.println("outputRow is:" + outputCurrency);
    
    System.out.println("This is the initial amount: " + input+ String.format("%.2f",amount));
    System.out.println("This is the conversion factor:" + currencies[outputCurrency][inputCurrency]);
   
     System.out.println("This is conversion:" + output  + String.format("%.2f",(currencies[outputCurrency][inputCurrency] * amount)));
     
     double convertedValue=0;
     double convertedBack=0;
     convertedValue = (currencies[outputCurrency][inputCurrency] * amount);
    
     System.out.println("This is the conversion factor:" + currencies[inputCurrency][outputCurrency]);
     System.out.println("This is conversion:" + input  +  String.format("%.2f",(currencies[inputCurrency][outputCurrency] * convertedValue)));
     
     
     
     convertedBack = currencies[inputCurrency][outputCurrency] * convertedValue;
     
     
}
}
        