Preparing table of a number by using loop

This tutorial will teach you the methods of preparing the
table of a given number by using loop condition. As we know the loop statements
are used to repeat a statement or process multiple times according to a
specified condition. Loop checks certain condition and if it finds the condition
is valuable then all the statements written under loop are executed.
Here we will take a number a=25 of which we have to prepare a
table. Define the integer a=25 and b=1 as the initial point. Now apply
"while" condition of loop and confine b<=10 as we have to make a
table of 25. Again define another integer as c=a*b, this will be the result when
we multiply 'a' with 'b'. Here we have to multiply 'a' with 'b' up to 10 times like
a*1, a*2....................a*9, a*10. So make define b=b+1 as increment
operator.
Now compile and run the program on the command window.
Here is the code of the prorgram:
class PreparingTable{
public static void main(String[] args) {
int a=25, b=1;
System.out.println("the table of "+a+"= ");
while(b<=10){
int c = a*b;
System.out.println(c);
b = b+1;
}
}
}
|
Download this example.

|
Current Comments
4 comments so far (post your own) View All Comments Latest 10 Comments:please show more examples with their output.
Posted by Anagha on Sunday, 10.5.08 @ 15:06pm | #80910
hi... i need a java project for showing in my class, but i hav very less time. if anyone can send me some projects ,thanks
Posted by jaswinder singh on Friday, 08.8.08 @ 12:06pm | #71741
I am very happy searching this site. I have problem in servlet for calculating the 10 products with different quantity and different price. Can any body help me how to write a code in servlet. Because in html page all 10 products with different quantity & different price are coded and connected to the servlet. At a time i have to select alteast 5 products or more than 5 products so kindly can any help me how to write a code for this.
Posted by santosh on Thursday, 01.24.08 @ 10:38am | #45982
please include the output for each example so the users can cross check with their output
Posted by visakh m g on Friday, 12.1.06 @ 12:36pm | #310