I get FC when running but it compiles.
NOTE: Changes have been made following Rasel’s comment’s. Still FC’s
btnExecute.setOnClickListener(new View.OnClickListener() //this worked
{
private AlertDialog show;
public void onClick(View arg0)
{ //start of get stack shape and provide area and equivalent diameter
//20110720
//just trying to evaluate the shape to use the correct inputs for area calculation
//I will then add and evaluate for the units of input to build universal
//values(_eng and _met)variables to use for all further calculations. KISS!
if (((m1_ss_spinner.getSelectedItem().toString().equals("Square")))) //cant compare a string with == operator. Use equals() to compare
{
if ((m1_sqs1.getText().length() == 0) //if m1_sqs1 is empty
|| (m1_sqs1.getText().toString().equals(""))) //if m1_sqs1 is blank
{
show = new AlertDialog.Builder(mContext).setTitle("Error") //this worked
.setMessage("The Square Side length is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_sqs1.getText().toString()) * new Double(m1_sqs1.getText().toString());
m1_sa_in.setText(Double.toString(result));
} //end of square area
} else
if (((m1_ss_spinner.getSelectedItem().toString().equals("Rectangle"))))
{
if ((m1_rs1.getText().length() == 0)
|| (m1_rs1.getText().toString().equals("")
|| (m1_rs2.getText().length() == 0)
|| (m1_rs2.getText().toString().equals(""))))
{
show = new AlertDialog.Builder(mContext).setTitle("Error")
.setMessage("A Rectangle Side length is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_rs1.getText().toString()) * new Double(m1_rs2.getText().toString());
m1_sa_in.setText(Double.toString(result));
} //end of rectangle area
} else
if (((m1_ss_spinner.getSelectedItem().toString().equals("Circle"))))
{
if ((m1_cd.getText().length() == 0)
|| (m1_cd.getText().toString().equals("")))
{
show = new AlertDialog.Builder(mContext).setTitle("Error")
.setMessage("The Circle Diameter is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_cd.getText().toString()) * new Double(m1_cd.getText().toString());
m1_sa_in.setText(Double.toString(result));
} //end of circle area
} else
if (((m1_ss_spinner.getSelectedItem().toString().equals("Elliptical"))))
{
if ((m1_els1.getText().length() == 0)
|| (m1_els1.getText().toString().equals("")
|| (m1_els2.getText().length() == 0)
|| (m1_els2.getText().toString().equals(""))))
{
show = new AlertDialog.Builder(mContext).setTitle("Error")
.setMessage("An Elliptical Diameter is empty")
.setPositiveButton("OK", null).show();
} else
{
double result = new Double(m1_els1.getText().toString()) * new Double(m1_els2.getText().toString());
m1_sa_in.setText(Double.toString(result));
}; //end of elliptical area
} // end of onClick code
}
});
Compiling seems to only verify code but not logic One needs to be very careful with code and I now recommend plenty of comments and strict format with indentions so if statements are easy to determine the beginning and end FCs occur when the program is left with decision it cant make