java - How do you round of this -


i'm working on number converter project on high school, , "length."
2 problems are:

  1. how round off result 0.00 value?
  2. how make exception allow decimal inputs shows error message if number not integer.

here code:

double a,a1,a2,a3,a4,a5,a6,a7;   double c1 = (double) (0.00062);   double c2 = (double) (39.3701);   double c3 = (double) (0.001);   double c4 = (double) (3.28084);   double c5 = (double) (1.09361); string b = "invalid user input";   try {  = integer.parseint(tl.gettext());     a1 = (a*1000);   a2 = (a*100);   a3 = (a*c1);   a4 = (a*c2);   a5 = (a*c3);   a6 = (a*c4);   a7 = (a*c5);    tl1.settext(string.valueof(a1));   tl2.settext(string.valueof(a2));   tl3.settext(string.valueof(a3));   tl4.settext(string.valueof(a4));   tl5.settext(string.valueof(a5));   tl6.settext(string.valueof(a6));   tl7.settext(string.valueof(a7));   } catch (exception z) // <<<< t_t   {    joptionpane.showmessagedialog(rootpane, b);   } 

you're trying assign int parsed value double variable, that´s causing error. should change integer.parseint double.parsedouble.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -