print the multiplication table up to one

Ads
 

print the multiplication table up to one

My problem is that I have to change the code so that the user can tell the program which factor that should be the highest one. An example: if the user tells the program that the highest factor should be 4, then the result should be: 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16

Thank├?┬┤s in advance!

import java.util.Scanner;

class Multiplication
{
public static void main(String args[])
{
int n, c;
System.out.println("Enter an integer to print it's multiplication table");
Scanner in = new Scanner(System.in);
n = in.nextInt();
System.out.println("Multiplication table of "+n+" is :-");

  for ( c = 1 ; c <= 10 ; c++ )  
     System.out.println(n+"*"+c+" = "+(n*c));

}
}

View Answers

March 14, 2012 at 6:05 PM

import java.util.Scanner;

class Multiplication
{
public static void main(String args[])
{
int n;
System.out.print("Enter the highest factor:");
Scanner in = new Scanner(System.in);
n = in.nextInt();
int[][] array = new int[11][n+1];
for (int i=1; i<array.length; i++) {
for (int j=1; j<array[i].length; j++) {
array[i][j] = i*j;
System.out.print(" " + array[i][j]);
}
System.out.println("");
}
}
}

March 14, 2012 at 6:09 PM

thanks alot!

Ads









Related Tutorials/Questions & Answers:
print the multiplication table up to one
print the multiplication table up to one  My problem is that I have...; System.out.println("Enter an integer to print it's multiplication table...(); System.out.println("Multiplication table of "+n+" is :-"); for ( c = 1 ; c <= 10
Multiplication table
Design and develop Multiplication table in Net beans  Design and develop a program that will print a multiplication table. The program should: Ask... table.   import java.util.Scanner; class Multiplication { public static
Advertisements
Multiplication table
Multiplication table Net Beans  Using Net beans Design and develop a program that will print a mulyiplication table.The program should; Ask the user for ending number than Display that particular multiplication table   
Multiplication table
Multiplication table  Using Net beans Design and develop a program that will print a mulyiplication table.The program should; Ask the user for ending number than Display that particular multiplication table   import
How to Create Multiplication Table from 1 to 10?
How to Create Multiplication Table from 1 to 10?  Hi, I want... table 1 to 10. Please suggest online example related to creating multiplication table. Thanks   Hi, Did you want to create multiplication table 1
how to insert one table to anothere table
how to insert one table to anothere table  i have insert the record one table then i retrve the value of that table i insert one value at a time
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products... enter the Quantity field in table 'Products_Purchased'In table 'Products' one item
multiplication
multiplication  multiplication of two number numbers entered by user minimum 100digits using GUI   Java Multiplication of two 100 digits number import java.awt.*; import java.math.*; import javax.swing.*; import
multiplication
multiplication  multiplication of two number numbers entered by user minimum 100digits using GUI   Java Multiplication of two 100 digits number import java.awt.*; import java.math.*; import javax.swing.*; import
Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below
Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below  HI, I have... the table rows up to view more underlying data, then, the table's header (1st row
excel parsing and print data in the form of table
excel parsing and print data in the form of table  my reqment is i have to parse the excel and i need to print the data in the table by using swing jtable or else ....can u give the solution please
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i...)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir   Have
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i...)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir   Have
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i...)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir   Have
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i...)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir   Have
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i...)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir   Have
how to fill up a form automaically from database and print it
how to fill up a form automaically from database and print it  sir,i...)should automatically fill up in the form and on cliking print button it shoulg give a print out. i need code for this in jsp .plsss help me sir   Here
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied to the 1st eid in appusers table, 2nd eid of employee to the 2nd eid of appusers
retrieve the records from one table to another table by using cursors
retrieve the records from one table to another table by using cursors  ... from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc
Mysql Multiplication Columns
Multiplication Columns'. To understand the example we simply create a table...;   Query for creating table name Multiplication: mysql> CREATE TABLE Multiplication( -> a int(10), ->
Mysql Multiplication Columns
a table 'Multiplication' with required fieldname and datatype respectively.       Query for creating table name Multiplication: mysql> CREATE TABLE Multiplication( -> a int(10
get data in pop up window droplists and on selecting data in the same show a grid table with related datas
a pop up window appears with two drop down lists and a button. One of the drop... pop up menu with a select button in each row.when I click any one select button...get data in pop up window droplists and on selecting data in the same show
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table
how to count unique and duplicate values from one table in mysql?
how to count unique and duplicate values from one table in mysql?  I have use EMP table.I want to count unique and duplicate records from emp table and how to use in java program
How to compare two tables, and insert values which r not in one table to another table?
How to compare two tables, and insert values which r not in one table to another table?  Hi I need to compare two tables MainTable and OUTTable... insert the values to main_table... here is my sql query insert into Main_Table
Parallel multiplication matrix in java
Parallel multiplication matrix in java  hello dear I need parallel multiply matrix in java algorithm to account speed up and efficiency great wishes
Hibernate One to One Mapping using XML
In this section, you will learn One to One mapping of table in Hibernate using Xml
how to move records from one table to other based on its creation time
how to move records from one table to other based on its creation time  Hi all,, As part of my requirement ,the records in one table have to move to second table based on the record creation time means the records should
Server side validation on dynamically generated fields from more than one table on spring framework.
Server side validation on dynamically generated fields from more than one table on spring framework.   Server side validation on dynamically generated fields from more than one table in spring mvc framework
Print
related objects. It's part of java.lang namespace. out: out being one of those... into the stream and, as opposed to print() method, gets you to the new line after the text
ModuleNotFoundError: No module named 'multiplication'
ModuleNotFoundError: No module named 'multiplication'  Hi, My... named 'multiplication' How to remove the ModuleNotFoundError: No module named 'multiplication' error? Thanks   Hi, In your python

Ads