Page 288 - CA_Blue( J )_Class9
P. 288
You will get the following output:
Enter 1st number : 10
Enter 2nd number : 8
**********
1. Sum
2. Difference
3. Product
4. Quotient
5. Remainder
Enter your choice : 1
***********
Sum of 10 and 8 is : 18
VARIABLE DESCRIPTION
NAME DATATYPE DESCRIPTION
st
num1 String Accept 1 Number
nd
num2 int Accept 2 number
sum int Sum of the numbers
pro int Product of the numbers
diff int Difference of the numbers
rem int Remainder of the numbers
quo double Quotient of the numbers
ch int Choice of user
(vii) Programs based on Looping Statement.
st
Program 11 Write a program to input a number and print 1 10 multiplication table of that number.
1 import java.util.*; //importing “util” package
2 class multiplicationtable //class name
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 int n, i; //declaration of variable
8 System.out.print("Enter a number whose multiplication table will
be generated : ");
9 n=sc.nextInt(); //Accepting value
10 for(i=1;i<=10;i++) //Loop to print multiplication
11 {
12 System.out.println(n + " x " + i + " = " + (n*i));
13 }
14 }}
286 Touchpad Computer Applications-IX

