[Go to site: main page, start]

0% found this document useful (0 votes)
2 views83 pages

Java Programs for Number Operations

The document contains a comprehensive list of Java programming exercises focused on number programs, recursion, arrays, strings, and collections. Each exercise is designed to enhance programming skills by addressing various concepts such as even/odd checks, factorial calculations, array manipulations, string operations, and collection handling. The exercises are attributed to Prathiksha Keni and cover a wide range of topics suitable for learners at different levels.

Uploaded by

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

Java Programs for Number Operations

The document contains a comprehensive list of Java programming exercises focused on number programs, recursion, arrays, strings, and collections. Each exercise is designed to enhance programming skills by addressing various concepts such as even/odd checks, factorial calculations, array manipulations, string operations, and collection handling. The exercises are attributed to Prathiksha Keni and cover a wide range of topics suitable for learners at different levels.

Uploaded by

praveenfrp1127
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA PROGRAMMING

 NUMBER PROGRAMS
1. WAJP to check whether a number is even or odd using if-else.

2. WAJP to check whether a number is even or odd using conditional


operator.

PRATHIKSHA KENI
JAVA PROGRAMMING
3. WAJP to check whether a number is even or odd using switch.

4. WAJP to check whether a number is even or odd without using modulus


operator.

PRATHIKSHA KENI
JAVA PROGRAMMING
5. WAJP to check whether a number is positive or negative.

6. WAJP to remove the last digit of a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
7. WAJP to print the last digit of a number.

8. WAJP to print the last digit of a number from its last place.

PRATHIKSHA KENI
JAVA PROGRAMMING
9. WAJP to find the sum of digits in a number.

10. WAJP to count the number of digits in a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
11. WAJP to print the even number from 1 to 50.

12. WAJP to print the odd number from 50 to 100.

13. WAJP to print the factors of a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
14. WAJP to count the factors of a number.

15. WAJP to check whether a number is PERFECT NUMBER or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
[Link] to check whether a number is PERFECT NUMBER using Methods
(If number is perfect return “Perfect Number” else return “Not a perfect
number”).

PRATHIKSHA KENI
JAVA PROGRAMMING
17. WAJP to print the PERFECT NUMBER within the Range (1 to 100).

18. WAJP to find the product of digits in a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
19. WAJP to find the sum of natural number from 1 to 10.

20. WAJP to find the sum of ‘n’ natural numbers using Scanner class.

PRATHIKSHA KENI
JAVA PROGRAMMING
21. WAJP to check whether the number is SPY NUMBER or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
22. WAJP to check whether a number is SPY NUMBER using Methods
(If number is spy return ‘true’ else return ‘false’).

PRATHIKSHA KENI
JAVA PROGRAMMING
23. WAJP to print ‘n’ SPY NUMBER.

24. WAJP to find the square of a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
25. WAJP to check whether the number is NEON NUMBER or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
26. WAJP to check whether a number is NEON NUMBER using Methods
(If number is neon return “hi” else return “bye”).

PRATHIKSHA KENI
JAVA PROGRAMMING
27. WAJP to print the NEON NUMBER within the Range (1 to 100).

28. WAJP to find the product of digits from 1 to 5.


OR
WAJP to find the factorial of a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
29. WAJP to check whether the number is STRONG NUMBER or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
30. WAJP to check whether a number is STRONG NUMBER using Methods
(If number is strong return ‘positive integer’ else return ‘negative
integer’).

PRATHIKSHA KENI
JAVA PROGRAMMING
31. WAJP to print the STRONG NUMBER within the Range (x to y).

PRATHIKSHA KENI
JAVA PROGRAMMING
32. WAJP to check a number is PRIME NUMBER or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
33. WAJP to check whether a number is PRIME NUMBER using Methods
(If number is prime return ‘true’ else return ‘false’).

PRATHIKSHA KENI
JAVA PROGRAMMING
34. WAJP to print the PRIME NUMBER within the Range (m).

PRATHIKSHA KENI
JAVA PROGRAMMING
35. WAJP to count the PRIME NUMBER within the Range (m).

PRATHIKSHA KENI
JAVA PROGRAMMING
36. WAJP to find the sum of PRIME NUMBER within the Range (m).

PRATHIKSHA KENI
JAVA PROGRAMMING
37. WAJP to swap 2 variables values by using temporary or 3rd variable.

38. WAJP to swap 2 variables values without using temporary or 3rd variable.

PRATHIKSHA KENI
JAVA PROGRAMMING
39. WAJP to find the nth power of a digit.
OR
WAJP to find the value of xn.

PRATHIKSHA KENI
JAVA PROGRAMMING
40. WAJP to find the square root of a number.

PRATHIKSHA KENI
JAVA PROGRAMMING
41. WAJP to check whether a number is ARMSTRONG or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
42. WAJP to print the Fibonacci series (10 numbers).

43. WAJP to reverse a given number (by storing it in a variable).

PRATHIKSHA KENI
JAVA PROGRAMMING
44. WAJP to check whether a number is PALINDROME or not.

[Link] to check whether a number is LEAP YEAR or not.

PRATHIKSHA KENI
JAVA PROGRAMMING
 RECURSSION PROGRAMS
1. WAJP to print the number from 1 to 5 without using loops.

2. WAJP to print even number from 1 to 10 without using loops.

PRATHIKSHA KENI
JAVA PROGRAMMING
3. WAJP to find the factorial of a number without using loops.

 ARRAYS PROGRAMS
1. WAJP to access the elements of array.

PRATHIKSHA KENI
JAVA PROGRAMMING
2. WAJP to read ‘n’ integer elements from user store it in a array and print it.

3. WAJP to print even elements present in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
4. WAJP to print odd elements present in an array.

5. WAJP to print even index elements present in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
6. WAJP to print odd index elements present in an array.

7. WAJP to find the sum of elements present in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
8. WAJP to find the largest elements present in an array.

9. WAJP to find the smallest elements present in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
10. WAJP to find the average of elements present in an array.

11. WAJP to read ‘n’ characters from user store it in an array and print it.

PRATHIKSHA KENI
JAVA PROGRAMMING
12. WAJP to print the prime number present in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
13. WAJP to add 5 employee objects into array and print the details.

PRATHIKSHA KENI
JAVA PROGRAMMING
14. WAJP to design a method to return the count of even and odd numbers in
an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
[Link] to reverse an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
16. WAJP to sort the array using BUBBLE SORT.

[Link] to find the nth largest element in an array using SORT METHOD.

PRATHIKSHA KENI
JAVA PROGRAMMING
18. WAJP to find the nth smallest element in an array using SORT METHOD.

19. WAJP to find the nth largest element in an array WITHOUT USING SORT
METHOD. (This program works only if the array elements are unique)

PRATHIKSHA KENI
JAVA PROGRAMMING
20. WAJP to find the nth smallest element in an array WITHOUT USING SORT
METHOD.

PRATHIKSHA KENI
JAVA PROGRAMMING
21. WAJP to find the frequency of all elements in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
22. WAJP to print the unique elements in an array. (not repeated)

PRATHIKSHA KENI
JAVA PROGRAMMING
23. WAJP to print the duplicate elements in an array. (repeated)

24. WAJP to find the key elements in an array. (LINEAR SEARCH)

PRATHIKSHA KENI
JAVA PROGRAMMING
25. WAJP to perform BINARY SEARCH.

PRATHIKSHA KENI
JAVA PROGRAMMING
26. WAJP to print the MISSING ELEMENTS in an array (from 1 to 10).

PRATHIKSHA KENI
JAVA PROGRAMMING
27. WAJP to MERGE TWO ARRAYS.

PRATHIKSHA KENI
JAVA PROGRAMMING
28. WAJP to add one element into particular index in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
29. WAJP to remove one element into particular index in an array.

PRATHIKSHA KENI
JAVA PROGRAMMING
30. Create a blue print of Student with states student id, name, age. Create
an array of student add student object into the array, sort the student
objects based on the id.

PRATHIKSHA KENI
JAVA PROGRAMMING
 STRINGS PROGRAMS
1. WAJP to convert character array to string.

2. WAJP to convert character array to string without using constructor of the


String class.

3. WAJP to prove strings are immutable.

PRATHIKSHA KENI
JAVA PROGRAMMING
4. WAJP to access all the character in a string.

5. WAJP to reverse a string.

PRATHIKSHA KENI
JAVA PROGRAMMING
6. WAJP to check whether a string is palindrome.

7. WAJP to count the total number of digits in a string.

PRATHIKSHA KENI
JAVA PROGRAMMING
8. WAJP to count the total number of alphabets in a string.

9. WAJP to count the vowels and consonants in a string.

PRATHIKSHA KENI
JAVA PROGRAMMING
10. WAJP to convert the alphabet from LOWERCASE to UPPERCASE.

11. WAJP to convert the alphabet from UPPERCASE to LOWERCASE.

12. WAJP to convert from LOWERCASE to UPPERCASE in a string. (without


using inbuilt method)

PRATHIKSHA KENI
JAVA PROGRAMMING
13. WAJP to convert from UPPERCASE to LOWERCASE in a string. (without
using inbuilt method)

14. WAJP to convert from LOWERCASE to UPPERCASE and VICE VERSA in a


string.

PRATHIKSHA KENI
JAVA PROGRAMMING
15. WAJP to find the sum of digits in a string.

16. WAJP to remove the space in a string.

PRATHIKSHA KENI
JAVA PROGRAMMING
17. WAJP to SWAP two strings (using 3rd variable).

18. WAJP to SWAP two strings (without using 3rd variable).

PRATHIKSHA KENI
JAVA PROGRAMMING
19. WAJP to print the occurrence of each character in a string (frequency).

20. WAJP to print the unique character in a string (non-repeated character).

PRATHIKSHA KENI
JAVA PROGRAMMING
21. WAJP to print the duplicate character in a string (repeated character).

22. String s = ”Qspiders@abc”; (Separate Vowel and Consonant)


Output 1: “iea”
2: “Qspdrsbc”

PRATHIKSHA KENI
JAVA PROGRAMMING
23. WAJP to check whether the string contains only digits.

Using Try catch block.

PRATHIKSHA KENI
JAVA PROGRAMMING
24. WAJP to validate a password.
Condition: -
 It should contain 8 to 14 characters
 It should contain at least one special character, uppercase alphabet,
lowercase alphabet, digit
 It should not contain spaces

PRATHIKSHA KENI
JAVA PROGRAMMING
25. WAJP to reverse a sentence (reverse the string word by word).

26. WAJP to reverse every word of a string character by character.

PRATHIKSHA KENI
JAVA PROGRAMMING
27. WAJP to convert string into Initcap. (Initial capital)

28. WAJP to print the occurrence of each word in a sentence (frequency).

PRATHIKSHA KENI
JAVA PROGRAMMING
29. WAJP to print the duplicate word in a sentence (repeated character).

30. WAJP to print the unique word in a sentence (non-repeated character).

PRATHIKSHA KENI
JAVA PROGRAMMING
31. WAJP to separate the alphabet and digit present in a string.

32. WAJP to print the sub set of a string.

PRATHIKSHA KENI
JAVA PROGRAMMING
33. WAJP to check if string is ANAGRAM.

34. WAJP to check if string is PANGRAM.

PRATHIKSHA KENI
JAVA PROGRAMMING
35. WAJP to find the length of string without using length method or
variable.

36. WAJP to find the total number of words in a string or sentence.

PRATHIKSHA KENI
JAVA PROGRAMMING
 COLLECTION PROGRAMS
1. WAJP to add 4 employee objects into array list and access in all ways.

PRATHIKSHA KENI
JAVA PROGRAMMING
2. Create a generic collection of students read the data from user.

PRATHIKSHA KENI
JAVA PROGRAMMING
3. Create a non-generic collection read the data from user and find the sum.

4. Create a generic collection read the data from user and find the sum.

PRATHIKSHA KENI
JAVA PROGRAMMING
5. WAJP to add 5 book objects into collection and design a method to
remove a book based on name.

PRATHIKSHA KENI
JAVA PROGRAMMING
6. WAJP to convert array list into hash set. (using in-built constructor)

WAJP to convert array list into hash set. (without using in-built
constructor)

PRATHIKSHA KENI
JAVA PROGRAMMING
7. WAJP to convert hash set into tree set. (using in-built constructor)

8. WAJP to convert tree set into hash set. (using in-built constructor)

PRATHIKSHA KENI
JAVA PROGRAMMING
9. WAJP to convert hash set into array list. (using in-built constructor)

[Link] to convert array list into tree set. (using in-built constructor)

PRATHIKSHA KENI
JAVA PROGRAMMING
[Link] to convert tree set into array list. (using in-built constructor)

12. WAJP to create collection of integer type and add elements in to it and
sort in ascending order.

PRATHIKSHA KENI
JAVA PROGRAMMING
13. WAJP to add 5 laptop objects into collection and sort the collection based
on id.

PRATHIKSHA KENI
JAVA PROGRAMMING
14. Create a Library application where it should have multiple methods to
perform adding and removing the book object from collection. Create one
add_book method to add one book object into the library, create the
remove_book method to remove a book from the collection based on id,
name and price. Design a sort_book method in order to sort the book
object based on the price.

PRATHIKSHA KENI
JAVA PROGRAMMING

PRATHIKSHA KENI
JAVA PROGRAMMING
• WAJP to find the LONGEST PALINDROME in a string.

PRATHIKSHA KENI

You might also like