Programming Assignment (Chap 01 – Chap 03) – by Indrajeet Sachdeva sir (St.
John’s School Marhauli)
PROGRAMMING ASSIGNMENT
(COMPUTER APPLICATIONS )
Instructions –
All programming questions to be completed before 15th September, 2021.
Writing variable description will be compulsory for all the programs.
The source code should be well documented.
1. WAP in Java to reverse a number. Example –Input 456, Output 654
2. WAP to check whether a number is Palindrome number or not.
Hint – A number whose reversed number is equal to the number itself is known as
Palindrome number. Example – 989 is a Palindrome number because reverse of 989
will be 989 itself.
3. WAP to check whether a number is Spy number or not.
4. WAP to check whether a number is Neon number or not.
Hint -
A positive integer whose sum of digits of its square is equal to the number itself is
called a neon number.
5. Write a program to accept a number and check and display whether it is a Niven
number or not.
(Niven number is that number which is divisible by its sum of digits).
6. Design n class to overload a function SumSeriesO as follows:
(i) void SumSeries(int n, double x) – with one integer argument and one double
argument to find and display the sum of the series given below:
1|Page
Programming Assignment (Chap 01 – Chap 03) – by Indrajeet Sachdeva sir (St. John’s School Marhauli)
(ii) void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 x 2) + (1 x 2 x 3) + ….. + (1 x 2 x 3 x 4 x 20)
7. WAP to check whether a number is Evil number or not.
8. WAP to display GCD of two numbers.
9. Write java methods to display the following patterns-
22
333
4444
55555
55555
4444
333
22
*****
****
***
**
2|Page
Programming Assignment (Chap 01 – Chap 03) – by Indrajeet Sachdeva sir (St. John’s School Marhauli)
11
121
1331
14641
10
101
1010
10101
1234554321
1234**4321
123****321
12******21
1********1
BB
CCC
DDDD
3|Page
Programming Assignment (Chap 01 – Chap 03) – by Indrajeet Sachdeva sir (St. John’s School Marhauli)
EEEEE
FFFFFF
SU
SUC
SUCE
SUCES
SUCCESS
10. A special two-digit number is such that when the sum of its digits is added to the
product of its digits, the result is equal to the original two-digit number. Example:
Consider the number 59.
Sum of digits = 5 + 9=14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the
product of its digits. If the value is equal to the number input, output the message
“Special 2-digit number” otherwise, output the message “Not a special 2-digit
number”.
11. Write a menu driven program to display the pattern as per user’s choice.
4|Page
Programming Assignment (Chap 01 – Chap 03) – by Indrajeet Sachdeva sir (St. John’s School Marhauli)
For an incorrect option, an appropriate error message should be displayed.
12. Using switch statement, write a menu driven program for the following : [15]
(i) To find and display the sum of the series given below :
S = x1 -x2 + x2 – x4 + x5 – x20
(where x = 2)
(ii) To display the following series :
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.
13. Using the switch statement, write a menu driven program for the
following: [15]
(i) To print the Floyd’s triangle [Given below]
2 3
4 5 6
7 8 9 10
11 12 13 14 15
5|Page
Programming Assignment (Chap 01 – Chap 03) – by Indrajeet Sachdeva sir (St. John’s School Marhauli)
(ii) To display the following pattern:
I C
I C S
I C S E
For an incorrect option, an appropriate error message should be displayed.
14. Design a class to overload a function series() as follows: [15]
(a) void series (int x, int n) – To display the sum of the series given below:
x1 + x2 + x3 + ……………. xn terms
(b) void series () – To display the sum of the series given below:
15. Design n class to overload a function SumSeriesO as follows: [15]
(i) void SumSeries(int n, double x) – with one integer argument and one double
argument to find and display the sum of the series given below:
(ii) void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 x 2) + (1 x 2 x 3) + ….. + (1 x 2 x 3 x 4 x 20)
6|Page