I am beginner in java programming. Don't know how to print table of a give number using loops. Please write me the program with source code.
How to create table in Java Language?
Hi friend. I think this code is useful for you.
***********************************
class PreparingTable{
public static void main(String[] args) {
int a=25, b=1;
System.out.println("the table of "+a+"= ");
while(b%26lt;=10){
int c = a*b;
System.out.println(c);
b = b+1;
}
}
}
***********************************
Reply:Do you want api table or simply printing in table format?
if simple table format then here u r
for(int i=0;i%26lt;5;i++)
{
for(int j=0;j%26lt;5;j++)
{
System.out.println(" "+j);
}
}
Reply:If it is for multiplication table, then use the below code(This is for multiplication table number 15). Please change the value of the MULTI_NBR to the required multiplication table number.
public class Multiply {
public static void main(String[] args) {
int MULTI_NBR = 15; // change this number for the required value
for (int i=1; i%26lt;=10; i++) {
System.out.println(MULTI_NBR + " x " + i + " = " + MULTI_NBR*i);
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment