Write a program to print the multiplication table until the product is less than 100.
Input (Integer) |
Printed Output |
2 |
2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 2 x 10 = 20
|
10 |
10 x 1 = 10 10 x 2 = 20 10 x 3 = 30 10 x 4 = 40 10 x 5 = 50 10 x 6 = 60 10 x 7 = 70 10 x 8 = 80 10 x 9 = 90 NOTE : (10 x 10 = 100) is not printed since the product 100 is not less than 100.
|
14 |
14 x 1 = 14 14 x 2 = 28 14 x 3 = 42 14 x 4 = 56 14 x 5 = 70 14 x 6 = 84 14 x 7 = 98
|
20 |
20 x 1 = 20 20 x 2 = 40 20 x 3 = 60 20 x 4 = 80
|
class PrintMultiplicationTableTill100
{
public static void main(String s[])
{
printMultiplicationTableTill100(12);
}
public static void printMultiplicationTableTill100(int input)
{
}
}
Topic:
Using Break In for Loop To Exit
If you need explanation Read this topic
If you need Answer Take test on this topic
User comments below. All of them might not be correct.
to print the table of a particular number we need to take a loop wich will chek whether the product is less than 100 or not.. for this firstly take a variable i=1 now... take while loop and the condition inside while loop will be -> while(input*i<100) so everytime the product is less than 100 it will enter into loop other wise it will exit.... now inside this loop... print ->> sop(input "*" i "="(input*i))....so the output will be printed in the desired frmat.... now increment the value of I by 1 as i .....now exit loop
Posted by Asma Mujtaba Khan 2014-12-12 06:30:11
*take and for loop start loop control from from the 1 and put condition until it is <=10
*here check whether product is <100 or not...if it is <100 than print else break to come out of the loop..
*print it like this Sopln(input+"*"+i+"="+i*input)
Posted by Uday Kumar 2014-12-12 14:17:11
This dose is now closed and the winners are Asma Mujtaba Khan, for 'First Correct Comment', Uday Kumar, for 'Second Correct Comment'. The 'lucky liker' is Shubham Bansal. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.
Posted by Merit Campus 2014-12-14 08:39:57