100% found this document useful (1 vote)
2K views

200 Java Programs

This document contains 100 practice programs for Class X Java covering various programming concepts like loops, arrays, strings, functions, sorting, searching, matrices, pattern printing, number systems, data types and more. The programs involve tasks like finding prime numbers, Armstrong numbers, sorting, reversing strings/numbers, pattern printing, factorials, checking number properties and more. Functions and different loops are used to implement logic for tasks like sorting, searching, pattern generation and calculations.

Uploaded by

Chirag Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

200 Java Programs

This document contains 100 practice programs for Class X Java covering various programming concepts like loops, arrays, strings, functions, sorting, searching, matrices, pattern printing, number systems, data types and more. The programs involve tasks like finding prime numbers, Armstrong numbers, sorting, reversing strings/numbers, pattern printing, factorials, checking number properties and more. Functions and different loops are used to implement logic for tasks like sorting, searching, pattern generation and calculations.

Uploaded by

Chirag Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICE PROGRAM FOR CLASS X

JAVA
1. Program to compute and print all prime numbers between 100 and 500.
2. Program to display all Armstrong numbers between 100 and 1000.
3. Program to create a 3x3 matrix and store the first nine natural numbers row wise. The program should further
display the sum of rows, columns and diagonals.
4. Program to display the name of the week day as per the entered number.
5. Write a program to input any number and print the same in reverse.
6. Program to display the sum and average of all even and odd numbers between 1 and 100.
7. Write a program to input any ten numbers and print the maximum and minimum.
8. Program to input a number and print its even factors.
9. Write a program to define a function factO to compute the factorial of any entered number.
10. Create a program to define a function found() to print the Highest Common Factor of any two numbers.
11. Write a program to define and utilize a function perfectO, to print all perfect numbers from 1 to 100. ( A perfect
number is a number which is equal to the sum of its factors eg. 6=1+2+3, hence 6 is a perfect number).
12. Write program to compute prime factors of any entered number with the help of a function pfactO.
13. Program to input a number and print its binary equivalent.
14. Sorting string using Bubble Sorting Technique.
15. Description: Its a simple program which calculates the day of the week for any given date & month of the year
2002.
16. Program to display the Pascal’s Triangle.
17. Develop a program to input any number and print them in descending order without using the sorting technique.
18. Code a program to compute the prime factors of any number using a function.
19. Program to display all prime fibonacci series between 1 to 10000.
20. Program to input any string and display the number of vowels.
21. Program which replaces each character in String s by the character which is at a distance of move ahead, if
move is positive. If move is 0 the original string is returned unchanged. If move is negative, then each character
is replaced by a character at a distance move behind it.
For example: When s=”ABCXYX”, encodeDecode(2) returns “CDEZAB” and When s=”ABCDE”,
encodeDecode(-3) returns “XYZAB”
22. Program to input a string and print each word in reverse.
23. Program to print the frequency of all the characters within a string.
24. Program to display the output as:
55555
54444
54333
54322
54321
25. Program to Sort an array using Bubble Sort Method.
26. Program to sort numbers using Selection Sort Method.
27. Program to sort any array of numbers using Insertion Sort Method.
28. Program to perform Binary Search in an array of numbers.
29. Program to perform Linear Search in a given array of numbers:
30. Displaying the sum of row and columns of a double dimension array.
31. Program to enter a number and sort the digits in ascending order. Display the new digit so obtained.
32. Store N elements in an array WORK and compute the total number of times M occurs in WORK. Where N and
M are the inputs alongwith the elements of the array. Program to print the frequency of M in an array of N
elements.
33. Program to input any number and check if it is a prime. Also implement the logic of display of all twin primes
within a given limit.
34. Program to compute the middle digit of any entered number. If the number does not have a middle digit, it has
to return the average of the middle two digits.
35. A palindrome number is one that reads same from left to right or right to left. There is an ingenious method to
get a palindrome from any positive integer. The procedure is as follows: Start with any positive number of 2 or
more digits. Obtain another positive number by reversing the digits of the starting number. Add the two numbers
together. Repeat the whole procedure with the sum as the starting number till you get a sum which is a
palindrome number. Program to calculate the palindrome of a given number in maximum 15 terms. Assume
that the starting number is not a palindrome. Sample Input: 87. Output: 4884 Steps: 4
36. Program to print the sum of factorial of the digits of an entered number.
37. Program to input any digit and display the sum of each digit where each digit is multiplied by 2 to the power of
its place value. For example if the number is 436 the output should be 4*22 + 3*21 + 6*20 = 28
38. Program to demonstrate the difference between prefix and postfix use of increment operators.
39. Example program to demonstrate the usage of implicit or automatic type conversion.
40. Example program to demonstrate the usage of if else statement
41. Program to input marks in five subjects and display the grade.
42. Program to enter a number and check if it is a prime.
43. Program to enter any number (max 3 digits) and check the nature of its digits.
44. Program to input a number and print its odd factors.
45. Program to input a number and print the average of its factors.
46. Example program to demonstrate the usage of relational operators.
47. Program to print the sum of two numbers or product of two numbers according to the entered choice 1-sum, 2-
product, 3 or any other from 1 or 2, display wrong code.
48. To calculate the factorial of any number using multiple initialization expressions.
49. Program to print prime factorization.
50. To print the sum of the folowing series:
s a/i + a/2 + a/3 + + a/n. Where a =2 and n=10 are the inputs.
51. 51. Program to print a triangle as follows:
1
12
123
1234
12345
52. To print the first ten terms of the fibonacci series.
53. To print the sum of first 100 natural numbers.
54. Program to enter a number and print the number of odd numbers from 1 to the number, even numbers and also
the summation of odd and even numbers.
55. Program to input a number and check if it is an armstrong number. A number is said to be Armstrong if it is
equal to the sum of the cubes of its digits.
56. Example Class to demonstrate the shorthand notation.
57. Program to input a number and print its even factors.
58. To calculate the square of any ten numbers.
59. Program : Using break and continue.
60. Program to display the following series. —1+2—3+4…..n
61. To Display the output as:
1234554321
1234 4321
123 321
12 21
11
62. Develop a C++ program to input any number and print the sum of its first and the last digit.
63. This program finds the integer between 1 and 10000 that has the largest number of divisors. It prints out the
maximum number of divisors and an integer that has that many divisors.
64. Class to input any two numbers and compute their LCM and HCF.
65. Special Number Program. A number is said to be special if the sum of factorial of each digit is equal to the
number.
66. Program to display all armstrong numbers between 100 and 1000 using arrays.
67. Program to input a number and print its binary equivalent.
68. Program to enter a number and sort the digits in ascending order. Display the new digit so obtained.
69. Example program to display the magic square of an entered value of n and x. Where n is the number of terms
required for the array (nxn) and x is the value of the first element.
70. This class allows the user to enter a number and than rounds it off, correct to the nearest integer.
71. Develop a program to input any number and print the sum of its digits.
72. Develop a program to input a list of elements in a double dimeiisional array of 3x3 and print the maximum and
the minimum elements alongwith their location within the array.
73. Program to extract and display the maximum prime digit from a number.
74. Program to enter a number and sort the digits in ascending order. Display the new digit so obtained.
75. Program to input a number and print its binary equivalent.
76. Program to enter any number and check the nature of its digits.
77. Program to print a triangle as follows:
1
12
123
1234
12345
78. Program to input any number and display the sum of its digits.
79. Program to check any entered number and check if it is a MAGIC NUMBER.
80. Program to create a MAGIC SQUARE BOX of nxn array with sum of all the rows equal to the sum of all the
columns.
81. Program to display a Triangle of numbers called the Pascal’s Triangle with input as the number of rows.
82. Program to enter a number and round it off to the nearest integer.
83. Program to sort a given array in descending order.
84. Program to display the maximum and minimum of a 3x3 matrix.
85. Program to arrange a given string in alphabetical order.
86. Program to print the reverse of any string.
87. Program to input name and marks in five subjects and compute the avg. and select eh subjects available.
88. Program to frame a simple calculator with functions like add, sub, mult, divide.
89. Program to sort a list of numbers generated randomly.
90. Program to print the first 20 numbers of the fibonacci series.
91. Program to compute the factorial of any entered integer.
92. Program to compute the average, standard deviation and sum of squares.
93. Program to display nested for looping.
94. Program to implement arithmetic on float values.
95. Program to implement relational operators.
96. Program to demonstrate Bitwise Operators of JAVA.
97. Program to display the following format:
11
1222
132333
98. Program to print the characters of the string present at odd positions.
99. Program to print the characters of the string present at even positions.
100. Program to input a number and print its sum and average of digits.
101. Program to print the characters of the string present at even positions.
102. Program to compute the sum of factorial of all the digits of any entered number.
103. Program to print the reverse of any entered string.
104. Program to input any number and print the factorial of its prime digits.
105. Program to display the sum of the following series S = 1+3+5+7....N where N is the input.
106. Program to display the following series -1+2-3+4....N where N is the input.
107. Program to print the sum of the even digits of an entered number
108. Program to print the number of the prime digits of an entered number
109. Program to print the number of the even digits of an entered number.
110. Program to print the maximum digit of an entered number.
111. Program to input any number and print the factorial of its digits.
112. Program to display the following series: 0+7÷26+63...+999.
113. Program to display the sum of the following series:
S = 1-3+5-7 N where N is the odd input.
114. Program to display the following series:
1
22
333
4444
55555...
N
115. Program to print the sum of the prime digits of an entered number.
116. Program to print the sum factors of each digit of an entered number.
117. Program to print the minimum digit of an entered number.
118. Program to print whether the sum of digits of an entered number is odd or even.
119. Program to print the factors of each digit of an entered number.
120. Program to print the sum of the odd digits of an entered number.
121. Program to display the following series:
1 12 123 1234 12345
122. Program to display the following series: +1/2-2/3+3/4-4/5. ...N where N is the input.
123. Program to display the sum of the following series: S = -1/(1+2)+2/(2+3)-3/(3+4)+4/(4+5) N/(N+(N+1)) where N
is the input.
124. Program to compute the sum of factors of all the digits of any entered number.
125. Program for printing number of words in a given string.
126. Program for printing the reverse of a given string.
127. Program to compute the length of each word of a sentence and print longest word.
128. Program to print the smallest word of an entered string.
129. Program for counting number of upper case and lower case.
130. Program for printing number of spaces in a given string.
131. Program to convert first letter of each word to capital case.
132. Program to compute the length of each word of a sentence and also display the longest word.
133. Program to display the Pascal’s triangle.
134. Program for counting number of upper case and lower case.
135. Program to display the salary sheet of the employee with member functions. input(), calc() and display()
methods.
136. Program to display the factorial of any entered number using the do-while loop.
137. Program to print the frequency of most occurring digit of an entered number.
138. Program to print the frequency of least occurring digit of an entered number.
139. Program to print the frequency of digits of an entered number.
140. Program to print the average of digits of an entered number.
141. Program to print the sum of cubes of each digit of an entered number.
142. Program to print the sum of square roots of each digit of an entered number.
143. Program to print the digits of an entered number in ascending order.
144. Program to print the sum of factors of each digit of an entered number.
145. Program to print the digits of an entered number in descending order.
146. Program to print the sum of squares of each digit of an entered number.
147. Program to calculate Y AX2 + BX + C when A, B and C are the inputs and X is greater than equal to .1 and less
than equal to 2.5.
148. Printing factorial of any entered number using a function with a calling argument.
149. Program to convert a given temperature in F to degree centigrade.
150. Program to print the sum of the following series: S=1+1/3+1/5+ +1/N.
151. Program to print the summation of any entered numbers.
152. Program to display Fibonacci numbers which are prime between I to 10000
153. Program to print prime factorization of a given number.
154. Program to display Fibonacci Heap.
155. Program to display the number of words in a given text.
156. Program to display the number of vowels in a given text.
157. Program to display the string in reverse
158. Program to check if the entered string is a palindrome.
159. Program to display the values of Z = (x2 + y2)/(x + y), where, x ranges from 0 to 50 and y remains constant at
5.
160. Compute sales tax and display it with an appropriate message with input value of sales.
161. Program to compute distance travelled at input value of time, velocity and acceleration.
162. Program to display the following series: 1 11 111 1111....N terms, where N is the input.
163. Program to display the following series: 54321 4321 321 21 1.
164. Program to compute the ASCII codes of each digit of any entered string.
165. Program to compute the sum of ASCII codes of the vowels present in a string.
166. Program to compute the sum of ASCII codes of any entered string.
167. Program to compute the sum of ASCII codes of digits present in the entered string.
168. Program to compute and print the maximum ASCII code and the character corresponding having the same of
entered string.
169. Program to compute total number of digits, lower, upper and other characters.
170. Program to print all the four letter unique combination of the four letter word SHAM.
171. Program to print the words with their size within an entered string.
172. Program to disply the upper case string into lower case using ASCII computation.
173. Program to display the lower case string into upper case using ASCII computation.
174. Program to display the frequency of all characters within a string.
175. Program to print all unique four letter combination of the word SHAM.
176. Program to print all combinations of an entered string starting with a particular letter.
177. Program to add sum of two time given in hours and minutes.
178. Program to add sum of two angles given in degrees and minutes.
179. Program to generate numbers to form the following computation. AB * CD = AD * BC
180. Program to input the week day and display the day.
181. Program to input the month number and display the month.
182. Program to input number of days and print year, days and weeks.
183. Program to input a text and decode the same by representing each character with its ascii codes.
184. Program to display the following series: 0 3 8 15 24 ....N terms, where N is the input.
185. Program to display the following series: 1! 2! 3’ N! terms, where N is the input and ! is factorial.
186. Program to check if the entered string is a prime palindrome.
187. Program to display the piglatin format of any string: - a string becomes piglatin when all the letters till the first
vowel are shifted in the end of the string in reverse order and “ay” is concatenated at the end. For example
input is KING the output will be NGIKAY
188. Program to draw the histogram of the given equation f(x)=x2+x+10, for the range of -5 to 5 of x.
189. Program to check whether a given year is a leap year or not.
190. Program to print the sum of the following series: S=1+(1+2)+(1+2+3)+ (1+2+...N)
191. Program to print the sum of the following series: S = 1*2 + 2*3 + 3*4 + n terms. Where n is the input.
192. Program to convert a given decimal number into binary.
193. Program to convert a given decimal number into octal.
194. User inputs five-digit number and then computer separates each number by 3 spaces.
195. This program will display all perfect numbers for numbers between 1 and 1000. The program should display the
perfect number along with the factors. eg. 6 = 1 +2 +3
196. Program to enter an amount and find out the coinage. Take any integer as input and describe the coinage (e.g
no. of 1000 rupees note, no. of 500 note, no. of 100 rupees till 5 rupees note.
197. Program to print the words with their size within an entered string.
198. Program to convert a given integer number into a given base (1-10).
199. Program to input the string, character to be searched and the character to be replaced. If character does not
exist print appropriate remark.(without using library functions) eg. input: tit for tat, output: pip for pap
200. Program to count the total number of children ‘c’, ladies ‘l’ and gents ‘g’ out any entered or assigned string.

You might also like