- 1
How to code this
Write a times table program. The program should ask a user to input a number in a dialogbox. This number is then used as the times table. So, if the user enters 10, the 10 times table should be displayed. Your Output window should look something like this, when your program is run.
5 Answers
+ 3
What language? Also show your attempt. We don't simply provide answers for homework here. This is a learning platform.
+ 3
You just copied this from your homework sheet, right? there is not "something like this" to look at.
If you want to solve it, learn the basics of a programming language (You did not tag any). Then try to print the table. Then look for a ui framework that allows you to create a window.
+ 1
package userinput;
import javax.swing.JOptionPane;
public class Program
{
public static void main(String[] args) {
String num1 = JOptionPane.showInputDialog("Number you wish to multiply");
int number = Integer.parseInt(num1);
int counter;
int product;
String result = "";
for (counter=1;counter<11;counter++)
{
product = number * counter;
result = counter + " times " +number+ " = "+product;
JOptionPane.showMessageDialog(null, result,"Product",JOptionPane.INFORMATION_MESSAGE);
}
}
}
0
package userinput;
import javax.swing.JOptionPane;
public class Program
{
public static void main(String[] args) {
JOptionPane.showInputDialog("Number you wish to multiply");
int number = Integer.parseInt(num1);
int counter;
int product;
String result = "";
for (counter=1;counter<11;counter++)
{
product = number * counter;
result = counter + " times " +number+ " = "+product;
JOptionPane.showMessageDialog(null, result,"Product",JOptionPane.INFORMATION_MESSAGE);
}
}
}
0
That is my attempt