Design a java application which takes input as a number in textfield and add the digits and display it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Design a java application which takes input as a number in textfield and add the digits and display it

23rd Jun 2017, 3:13 PM
Roniya Khatwaani
Roniya Khatwaani - avatar
11 Answers
+ 3
try parse integer from that string then in a loop you can do some operations to get every digit and finally sum of them
23rd Jun 2017, 3:24 PM
Hetbo.net
Hetbo.net - avatar
+ 1
So on Netbeans you drag a textfield on your JFrame. Add a button. add a label as lblOut Double click the button. do lblOut.setText(textfield.getText());
23rd Jun 2017, 3:19 PM
Limitless
Limitless - avatar
+ 1
ah. You'll need to do int x = Integer.Parse(TextField.getText());
23rd Jun 2017, 3:20 PM
Limitless
Limitless - avatar
+ 1
also use try and catch to display that it's a wrong input
23rd Jun 2017, 3:20 PM
Limitless
Limitless - avatar
+ 1
😊
23rd Jun 2017, 3:26 PM
Hetbo.net
Hetbo.net - avatar
+ 1
If you're still unsure you can always look at this code https://code.sololearn.com/cBxWC7KgA6EC/?ref=app
23rd Jun 2017, 3:29 PM
Limitless
Limitless - avatar
0
So where's your problem?
23rd Jun 2017, 3:15 PM
Limitless
Limitless - avatar
0
simple😀what's the problem
23rd Jun 2017, 3:16 PM
Hetbo.net
Hetbo.net - avatar
0
Problem is how can we add digits which are taken as input in textfield
23rd Jun 2017, 3:19 PM
Roniya Khatwaani
Roniya Khatwaani - avatar
0
Actually i have to add the digits of the number taken in taken in textfield and then display it..... So i want to know how to do dat
23rd Jun 2017, 3:23 PM
Roniya Khatwaani
Roniya Khatwaani - avatar
0
Yeah thankyou..... For help.....
23rd Jun 2017, 3:25 PM
Roniya Khatwaani
Roniya Khatwaani - avatar