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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -