Code Working Perfectly In Java CRASHES In Android Studio : I am new to android programming and am trying to the program to run but the problem is that the app builds and runs successfully but crashes whenever I press the GO button. My professor gave me this to accomplish as something to get started with android programming as he thought it would be challenging task that will be motivational and interesting. I looked everywhere for the solution but could not find it. My professor himself is unable to debug the code and hence. 

The code is as given below :

    **CODE 1**  

    package com.example.thispc.myapplication;
    import android.annotation.SuppressLint;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
    import android.widget.EditText;

    import java.util.Scanner;

    import edu.princeton.cs.algs4.EdgeWeightedDigraph;
    import edu.princeton.cs.algs4.DirectedEdge;
    import edu.princeton.cs.algs4.BellmanFordSP;

    public class Arbitrage extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_arbitrage);

        Button Check_Arbitrage = findViewById(R.id.Check_Arbitrage);
        Check_Arbitrage.setOnClickListener(new View.OnClickListener() {
            @SuppressLint("SetTextI18n")
            @Override
            public void onClick(View view) {

                EditText inputcurrencynumber;
                EditText inputdata;
                TextView outputarbitrage;
                inputcurrencynumber = findViewById(R.id.GetNoCurrencies);
                inputdata = findViewById(R.id.currency_table_input);
                outputarbitrage = findViewById(R.id.result);

                inputcurrencynumber = findViewById(R.id.GetNoCurrencies);
                int V;
                V = Integer.parseInt(inputcurrencynumber.getText().toString());
                outputarbitrage = findViewById(R.id.result);



                double rate,stake;

                inputdata = findViewById(R.id.currency_table_input);

                EdgeWeightedDigraph G = new EdgeWeightedDigraph(V);
                outputarbitrage.setText("Hello World");

                String [] name = new String[V];
                // The error occures here when i try to take an input
                for (int v = 0; v < V ; v++)
                {`enter code here`
                    name[v] = inputdata.getText().toString();
                    for (int w = 0; w < V ; w++)
                    {
                        rate = Double.parseDouble(inputdata.getText().toString());
                        DirectedEdge e = new DirectedEdge(v, w, -Math.log(rate));
                        G.addEdge(e);

                    }
               }

                BellmanFordSP spt = new BellmanFordSP(G,0);


                if (spt.hasNegativeCycle())
                {
                    stake = 1000;
                    for (DirectedEdge e : spt.negativeCycle())
                    {
                        //outputarbitrage.setText((Double.toString(stake) + name[e.from()]) + "  " + (Double.toString(stake) + name[e.to()]) + "\n");


                        outputarbitrage.setText("%10.5f %s " + stake + name[e.from()]);
                        stake = stake * Math.exp(-e.weight());
                        outputarbitrage.setText("= %10.5f %s\n" + stake + name[e.to()]);
                    }
                }

                else
                {
                    outputarbitrage.setText("No Arbitrage Opportunity Found");
                }
            }
        });

    }
}

Thanks