0% found this document useful (0 votes)
64 views6 pages

Computer Project-2

The document contains 25 questions related to writing programs in Java to perform various mathematical and logical operations. The questions include writing programs to: 1) Calculate the perimeter and area of a triangle given its three sides. 2) Check if a number is a "sunny number" using the ternary operator. 3) Check if a number is prime. 4) Check if a number is a palindrome. 5) Calculate the grade based on marks in English.

Uploaded by

Samrat Banerjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views6 pages

Computer Project-2

The document contains 25 questions related to writing programs in Java to perform various mathematical and logical operations. The questions include writing programs to: 1) Calculate the perimeter and area of a triangle given its three sides. 2) Check if a number is a "sunny number" using the ternary operator. 3) Check if a number is prime. 4) Check if a number is a palindrome. 5) Calculate the grade based on marks in English.

Uploaded by

Samrat Banerjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

0Project – 2 (Computer Applications)

Questions
1. Write a program to input 3 sides of a triangle
and find the perimeter and area of the triangle.
If a, b, and c are the 3 sides then,
Perimeter = a+ b+c
a+b+ c
Area = √ s ( s−a )( s−b ) ( s−c ) where s = 2

2. A number n is said to be a sunny number if, √ n+1 is


equal to an integer. For example, 8 is sunny as
√ 8+1 = 3 which is an integer. Write a program to
input a number and using the ternary operator
check whether it is a sunny number or not.
3. Write a program to accept a number. Check and
print whether it is a prime number or not.
A prime number is a number which is divisible by
1 and itself only. For example, 2, 3, 5, 7, 11, 13
are all prime numbers.
4. Write a program to accept a number from the
user and check whether it is a palindrome
number or not. A number is a palindrome which
when reads in reverse order is same as in the
right order. For example, 242 is a palindrome
number.
5. Write a program to input the marks in English
and find the grade obtained, depending upon the
following criteria:
Marks in English Grade
90 and above A
70 to 89 B
50 to 69 C
35 to 49 D
Below 35 E
6. A cloth showroom has announced the following
festival discounts on the purchase of items,
based on the total cost of the items purchased:
Total cost Discount (in
Percentage)
Less than Rs.2000 5%
Rs.2001 to Rs.5000 25%
Rs.5001 to Rs.10000 35%
Rs.10000 and above 50%
7. Pg.159 Q14
8. Pg.166 Q17
9. A prime number is said to be 'Twisted Prime', if
the new number obtained after reversing the
digits is also a prime number. Write a program to
accept a number and check whether the number
is 'Twisted Prime' or not. For example, 167 is
‘Twisted Prime’ because 761 is a prime no.
10. A Dudeney number is a positive integer that
is a perfect cube such that the sum of its digits
is equal to the cube root of the number. Write a
program to input a number and check and print
whether it is a Dudeney number or not. For
example, 512 is a Dudeney number as sum of
digits of 512 = 8 and cube root of 512 = 8.
11. Write a program to enter two numbers and
check whether they are co-prime or not. Two
numbers are said to be co-prime, if their HCF is
1. For example, 14, 15 are co-prime.
12. Write a program to accept a number and
check whether it is a 'Spy Number' or not. A
number is spy if the sum of its digits equals the
product of its digits. For example, 1124 is a spy
number as sum of the digits = 8 and product of
the digits = 8
13. Write a program in Java to find the sum of
the given series:
S = a + a2 / 2 + a3 / 3 + …… + a10 / 10
14. Pg.203 Q23
15. Pg.204 Q26
16. Using switch statement, write a menu driven
program for the following:
(a) To find and display the sum of the series
given below:
S = x1 - x2 + x3 - x4 + x5 - ………… - x20; where x = 2
(b) To display the series:
1, 12, 123, 1234, 12345
For an incorrect option, an appropriate error
message should be displayed.
17. Write a program in Java to input the values
of x and n and print the sum of the following
series:
S = 1 + (x+2)/2! + (2x+3)/3! + (3x+4)/4! + ……… to
n terms
18. Write a program to compute and display the
sum of the following series:
S = (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) +
-------- + (1 + 2 + 3 + ----- + n) / (1 * 2 * 3 * -----
* n)
19. Write a program to print the series:
0, 3, 8, 15, 24, ………… to n terms. (Value of 'n' is
to be an input by the user)
20. Write a program in Java to find the sum of
the following series:
S = a - (a/2!) + (a/3!) - (a/4!) + ……. to n
21. Pg.205 Q42
22. Write a program in Java to display the
following pattern:
54321
4321
321
21
1
23. Write a program to input a number. Check
and display whether it is a Niven number or not.
A number is said to be Niven which is divisible by
the sum of its digits. For example, 126 is a Niven
number as sum of its digits = 9 and 126 is
divisible by 9.
24. Pg.168 Q22
25. Write a program to compute and display the
sum of the following series:
S = (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) +
-------- + (1 + 2 + 3 + ----- + n) / (1 * 2 * 3 * -----
* n)

SEE EDGE COLLECTIONS FOR QUESTIONS

You might also like