WHAT IS WRONG WITH MY PROGRAM | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

WHAT IS WRONG WITH MY PROGRAM

Creating times table using dialog box, JOptionPane package userinput; import javax.swing.JOptionPane; public class Program { public static void main(String[] args) { int number, multiplier; JOptionPane.showInputDialog("Number you wish to multiply"); for (multiplier=1;multiplier<=10;multiplier++ ) { JOptionPane.showMessageDialog(null, "%d * %d = %d/n", number, multiplier,(number * multiplier)); } } }

6th Oct 2022, 12:28 PM
great Nile
2 Answers
+ 4
As far as I understand, SoloLearn does not have a file with this library, so your code will not work here. I don't understand this library, but judging by logic your code should look something like this: package userinput; import javax.swing.JOptionPane; public class Program { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Number you wish to multiply"); int number = Integer.parseInt(input); for(int multiplier=1;multiplier<=10;multiplier++){ JOptionPane.showMessageDialog(null, ("%d * %d = %d\n", number, multiplier, number * multiplier)); } } }
6th Oct 2022, 1:49 PM
Solo
Solo - avatar
+ 1
Is it the same as this? https://www.sololearn.com/Discuss/3090236/?ref=app I can't test the ui on sololearn. Do you want to display each calculation individually?
6th Oct 2022, 1:25 PM
Lisa
Lisa - avatar