When I run this program i get the error Exception in thread "main" java.lang.NumberFormatException: empty String. Is it possible to make this work?Could we import diff projects into a single project? When I run this program i get the error Exception in thread "main" java.lang.NumberFormatException: empty String. Is it possible to make this wor
package com.example.nav1;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
public class SgpaActivity extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootview = inflater.inflate(R.layout.activity_sgpa, container,
false);
// onButtonClick(view);
EditText e1,e2,e3,e4,e5,e6 =null;
e1 = e2 =e3 = e4 =e5 =e6;
TextView t1 = null;
float num1=0;
e1 = rootview.findViewById(R.id.e1);
e2 = rootview.findViewById(R.id.e2);
e3 = rootview.findViewById(R.id.e3);
e4 = rootview.findViewById(R.id.e4);
e5 = rootview.findViewById(R.id.e5);
e6 = rootview.findViewById(R.id.e6);
t1 = rootview.findViewById(R.id.result);
if(e1!=null)
num1 = Float.parseFloat(e1.getText().toString());
float num2 = Float.parseFloat(e2.getText().toString());
float num3 = Float.parseFloat(e3.getText().toString());
float num4 = Float.parseFloat(e4.getText().toString());
float num5 = Float.parseFloat(e5.getText().toString());
float num6 = Float.parseFloat(e6.getText().toString());
float sum = 0;
sum = (num1*25) + (num2*25) + (num3*25) + (num4*25) + (num5*23) +
(num6*23) ;
float cgpa = sum/(25+25+25+25+23+23);
t1.setText(Float.toString(cgpa));
return inflater.inflate(R.layout.activity_sgpa, container,false);
}
public void onButtonClick (View v)
{ // return inflater.inflate(R.layout.article_view, container, false);
}
}
I expect the output of 1 , 1, 1, 1, 1,1 be 1