android - How to compare this double value to find the result? -


its not working. here code activity. write? causez value of result not working in if else statement!!

package com.android.don.myapplication;  public class mapactivity extends actionbaractivity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_map);     }      public void checkbuttonclicked(view view)     {         radiobutton maleradiobutton, femaleradiobutton;         edittext height = (edittext)findviewbyid(r.id.edittext);         edittext weight = (edittext)findviewbyid(r.id.edittext2);         textview show = (textview) findviewbyid(r.id.resultview);         float h,w;         double result;         maleradiobutton = (radiobutton) findviewbyid(r.id.maleradio);         femaleradiobutton = (radiobutton) findviewbyid(r.id.femaleradio);         if (maleradiobutton.ischecked()) {             h = float.parsefloat(height.gettext().tostring());             w = float.parsefloat(weight.gettext().tostring());             result = (h/((w*0.025)*(w*0.025)));             toast.maketext(mapactivity.this,"answer "+result,toast.length_long);              if (result < 18.500) {                 show.settext("uw");             }             else if (result < 25.000) {                 show.settext("nm");             } else if (result < 30.000) {                 show.settext("ow");             }             else if (result>30.000){                 show.settext("vvm");             }          }         else if (femaleradiobutton.ischecked())         {             h = float.parsefloat(height.gettext().tostring());             w = float.parsefloat(weight.gettext().tostring());             result = (h/((w*0.025)*(w*0.025)));             //toast.settext(mapactivity.this,"value of a: " + string.valueof(result),toast.length_long);             if (result < 16.500) {                 show.settext("uw");             }             else if (result < 22.000) {                 show.settext("nm");             } else if (result < 27.000) {                 show.settext("ow");             } else if (result>30.000){                 show.settext("vvm");             }         }          else {             toast.maketext(getapplicationcontext(), "select gender", toast.length_short).show();          }     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_map, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     }  } 

try convert values double, not of them float , other double , following:

double h,w, result;  h = double.parsedouble(height.gettext().tostring()); w = double.parsedouble(weight.gettext().tostring()); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -