java - In Work Calculator -
i'm trying calculator need multiplication . gave example. imagine 2 jtextfield. need data wrote these jtextfields, , multiplicate them. , show result , jtextfield3. work needs work under action performend jbutton. can easy guys didnt understand. reading..
num1=integer.parseint(txtfield1.gettext()); num2=integer.parseint(txtfield2.gettext()); total=num1*num2; totalfield.settext(string.valueof(total));
note:i tried code didnt work. need that.
i need new code entire code did said on question . ok i'm nut giving order , please me. or should ?
2 problems code can see:
- numberformatexception isn't caught
- ints not declared
use instead:
try{ int num1=integer.parseint(txtfield1.gettext()); int num2=integer.parseint(txtfield2.gettext()); int total=num1*num2; totalfield.settext(integer.tostring(total)); } catch(numberformatexception e) { totalfield.settext("error in input"); }
Comments
Post a Comment