You are on page 1of 2

Multiple Table codes public static void main(String[] args) { // public static void main(String[] args) { // TODO code

application logic here //Declaration of my variables // This variable will hold the number that will be entered by the user String myString; //Following are the variables that will help me manipulate my data int number = 1, countRow =1, countColumn = 0, product = 1; //Get the number from the user myString = JOptionPane.showInputDialog("Enter a number"); //Convert the string into an integer number = Integer.parseInt(myString);

//Iterate to produce the rows while (countRow <= number){ //Reset the counter of the column to 1 so that the printing is done from the first column countColumn = 1; //iterate to produce the columns while (countColumn <= number){ product = countColumn * countRow; //Print the product of the column and the row and print the tab System.out.print (+product+"\t"); //increment the number of column so that at the next turn of the loop we move to the next column countColumn++; }

//Create a new line to allow data of the next column to be printed from the next line System.out.print ("\n"); //Increment the number of row countRow++;

} }

You might also like