
How i create table on showMessageDialog using JOptionpane and Integer.parseInt. No other method to use. Pl make a program which generate 5X1=5 5X2=10 5X3=15

Hi Friend,
Try this:
import javax.swing.*;
import java.io.*;
class CreateTable{
public static void main(String[] args)throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringBuffer buffer=new StringBuffer();
System.out.println("Enter number: ");
String st=br.readLine();
int n=Integer.parseInt(st);
int result;
for (int a = 1; a <= 10; a++)
{
result = n * a;
buffer.append(n);
buffer.append(" * ");
buffer.append(a);
buffer.append(" = ");
buffer.append(result);
buffer.append("\n");
}
JOptionPane.showMessageDialog(null,buffer.toString());
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.