Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners print the multiplication table up to one
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Tzio Tzi
print the multiplication table up to one
2 Answer(s)      2 years and 6 months ago
Posted in : Java Beginners


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));

}
}


Advertisement
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!



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
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
Create Multiplication Table from 1 to 10
Create Multiplication Table in Java In this section, you will learn how to create multiplication table from 1 to 10. For this purpose, we have created 2-dimensional Array 'array[][]' and using the for loop, we have stored the product
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
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
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
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
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
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
Mysqldump one table - Taking dump of only one table
Use of mysqldump for taking backup of one table In this section you will see the example of mysqldump function which takes the backup of only one table... user requirement. You can specify the name of table be backup in while executing
Copy One Database Table to Another
Copy One Database Table to Another       In this section, you will learn to copy one database table to another database table. That means we copy one table to a different table
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
Matrix multiplication
Matrix multiplication  program to read the elements of the given two matrices of order n*n and to perform the matrix multiplication
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
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
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
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
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
Advertisements
 

 

 

DMCA.com