Java - Programs List
Java - Programs List
Programs List
Write a Program to:
2. Compute addition of two numbers. (Subtraction, Multiplication, Division, to find the Remainder).
18. To enter marks of five subjects and calculate total, average and percentage.
21. Enter two angles of a triangle and find the third angle.
1
Problem Solving and Programming
24. Read floating point number and to print right most digit of integral part.
27. To compute the net salary of an employee by considering the formula, Net salary = Basic salary
+DA+TA+HRA -LIC where DA, TA, HRA and LIC are supplied as the input.
29. Input any number from user and check whether nth bit of the given number is set (1) or not (0)(hint:
Conditional Statements:
39. To check whether number a number is positive or negative or Zero (Using Switch / Nested if else).
44. Develop a calculator to convert time, distance, area, volume and temperature from one unit to
another.
a. else if ladder
b. switch
49. Program that keeps a number from the user and generates an integer between 1 and 7 and displays
50. Program that reads in two floating-point numbers and tests whether they are the same up to three
decimal places.
Looping Statements:
55. To print the even series. (Till ‘nth term’ / First ‘n’ Numbers)
56. To print the odd series. (Till ‘nth term’ / First ‘n’ Numbers)
57. To print the AP series (Inputs: first number of the series, common difference and last number).
58. Retrieve remainder after division of two numbers without using mod operator.
61. To print the natural number series and its sum till ‘n’.
62. To print the even series and its sum with total number of even numbers within ‘n’.
3
Problem Solving and Programming
63. To print the odd series and its sum with total number of odd numbers within ‘n’.
71. To find the power of a given number without using inbuilt function pow ( ).
73. To print the factors of a given number and total numbers of factor.
75. To find the sum of digits of a given number till the resulting number is a single digit.
81. To Print Whether the given number is perfect number or not. (for a perfect number, the sum of
divisors- except the number itself-will be equal to that number; Exs: 6,28,496,etc.).
86. To Print Twin Primes up to a Specified limit. (Exs: 3-5,5-7,11-13, 17-19, etc.)
4
Problem Solving and Programming
90. To find square root of a given number without using square root function.
a.
*
**
***
****
*****
b.
1
12
123
1234
12345
c.
A
BB
CCC
5
Problem Solving and Programming
DDDD
EEEEE
d.
1
23
456
7 8 9 10
e.
*****
****
***
**
*
f.
12345
1234
123
12
1
g.
*
***
*****
*******
*********
h.
1
232
34543
4567654
567898765
i.
33333
32223
32123
32223
33333
6
Problem Solving and Programming
101. To find largest among three numbers using binary minus operator.
105. Check the input number is a Neon Number or not. (Neon number is a number where the sum
of digits of square of the number is equal to the number itself. Ex: 9 is a Neon Number – 9*9 =81,
where 8+1=9)
106. Check the input number is an Automorphic Number or not. (Automorphic number is a
number whose square ends in the same digit as the number it self. Ex: 5 – Square ends with 5 (25))
107. Check the input number is a Spy Number or not. ( A spy number is a number where the sum
of its digits equals the product of its digits. For example, 1124 is a spy number, the sum of its digits
108. Check the input number is a Happy Number or not. ( Happy number is a number which
eventually reaches 1 when replaced by the sum of the square of each digit. For instance, 13 is a
109. Check the input number is a Sunny Number or not. ( A number n is called Sunny number if
the next number (n+1) is a perfect square number. For example 15 is a Sunny number because 15+1
110. Check the input number is a Fascinating Number or not. ( Fascinating Number: When a
number( 3 digits or more ) is multiplied by 2 and 3, and when both these products are concatenated
with the original number, then it results in all digits from 1 to 9 present exactly once. There could be
any number of zeros and are ignored. Examples: Input: 192. is an Fascinating Number because After
multiplication with 2 and 3, and concatenating with original number, resultant number is 192384576
7
Problem Solving and Programming
111. Check the input number is a Disarium Number or not. ( A disarium number is a number in
which the sum of the digits to the power of their respective position is equal to the number itself
(position is counted from left to right starting from 1). Hence,175 is a disarium number).
112. Check the input number is a Pronic Number or not. ( Pronic number is a product of two
consecutive integers of the form: n(n+1). For example: 6 = 2(2+1)= n(n+1), 72 =8(8+1) = n(n+1)).
113. Check the input number is a Trimorphic Number or not. ( A number is called Trimorphic
number if and only if its cube ends in the same digits as the number itself. In other words, number
114. Check the input number is Evil or Odious Number. (An odious number is a nonnegative
number that has an odd number of 1s in its binary expansion. An Evil number is a nonnegative
116. To Compute the Speed of a Vehicle based on the input distance in KM and time in HR.
117. To Compute the next dividend of the input dividend and divisor.
(Ex1: 2 divides 10 by giving the remainder as 0, hence 10 is the perfect dividend and the next
Ex2:7 failed to divide 10 by giving the remainder as 0, hence first need to find the perfect
dividend and then need to compute the next dividend as perfect dividend + divisor. So we got
Arrays:
119. To find the sum and average of all the elements in the array.
120. To find the largest element and its position in the array.
122. To find the sum of odd elements and even elements stored in an array.
8
Problem Solving and Programming
124. To generate 100 random integers in the range 1-100, store them in an array and print the
average.
125. To print the average of the given numbers and also the numbers greater than the average.
C[0]=a[0]+b[9]
C[1]=a[1]+b[8]
C[2]=a[2]+b[7]
C[3]=a[3]+b[6]
C[4]=a[4]+b[5]
C[5]=a[5]+b[4]
C[6]=a[6]+b[3]
C[7]=a[7]+b[2]
C[8]=a[8]+b[1]
C[9]=a[9]+b[0]
132. To delete the duplicate elements from an array.
133. Program to find element from an sorted array using binary search (java.util.package)
134. Program that reverses an array and stores it in the same array.
137. To find the sum of all the elements in 2D – array with m*n size.
9
Problem Solving and Programming
142. To find the row sum and column sum of the matrix.
143. To find the trace (sum of principle diagonal elements) of the matrix.
Strings:
154. Program to read a string and replace all the vowels with a ‘$’ symbol.
155. Program to count the number of occurrences of a search string in a given text string.
156. To check if two strings are the same ignoring their cases
10