0% found this document useful (0 votes)
3 views

Java - Programs List

Uploaded by

Manjusagar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java - Programs List

Uploaded by

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

Problem Solving and Programming

Programs List
Write a Program to:

1. Print “Hello World”

2. Compute addition of two numbers. (Subtraction, Multiplication, Division, to find the Remainder).

3. Compute the Simple Interest.

4. Compute the Compound Interest.

5. Compute the area of Circle, Rectangle, Triangle and Square.

6. Compute the Circumference of circle.

7. Find the area of triangle when three sides are given.

8. Compute the Perimeter of Rectangle.

9. To find the area of trapezium.

10. To find the area of rhombus.

11. To find the area of parallelogram.

12. To find the volume and surface area of cube.

13. To find the volume and surface area of cuboids.

14. To find the volume and surface area of cylinder.

15. To find the surface area and volume of a cone.

16. To find the volume and surface area of sphere.

17. To find the perimeter of a circle and triangle.

18. To enter marks of five subjects and calculate total, average and percentage.

Expressions and Operators:

19. Swap the content of two variables using temp.

20. Swap the content of two variables without using temp.

21. Enter two angles of a triangle and find the third angle.

1
Problem Solving and Programming

22. Find greatest of two numbers using conditional operators ( ?: )

23. Find the greatest of three numbers using conditional operator.

24. Read floating point number and to print right most digit of integral part.

25. Convert temperature from degree Celsius to Fahrenheit. ( Fahrenheit to Celsius)

26. To Conversion of an Upper-case character to a Lower-case character. (Vice Versa)

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.

28. To find out root of any number.

29. Input any number from user and check whether nth bit of the given number is set (1) or not (0)(hint:

Use bitwise operators)

30. Check Least Significant Bit (LSB) of a number

31. To shift input data two bits to the left.

32. Swapping of two numbers using Bitwise Operators.

Conditional Statements:

33. Check whether the triangle is equilateral, isosceles, or scalene triangle.

34. To find the greater (smallest) of two numbers.

35. To find the greatest (smallest) of three numbers.

36. To check whether given number is even or odd.

37. To check whether a given number is zero or not .

38. To check whether number a number is positive or negative.

39. To check whether number a number is positive or negative or Zero (Using Switch / Nested if else).

40. To find that the enter year is leap year or not.

41. To check whether a given character is vowel or consonant.

42. Check whether a number is divisible by 5 and 11 or not.

43. To perform the simple calculator operation.


2
Problem Solving and Programming

44. Develop a calculator to convert time, distance, area, volume and temperature from one unit to

another.

45. To check whether the input is number or not.

46. To check whether the person is eligible for voting or not.

47. To find the roots of an quadratic equation using

a. else if ladder

b. switch

48. For student grading system.

49. Program that keeps a number from the user and generates an integer between 1 and 7 and displays

the name of the weekday.

50. Program that reads in two floating-point numbers and tests whether they are the same up to three

decimal places.

Looping Statements:

51. To print your name ‘n’ times.

52. To find the sum and average of ‘n’ input numbers.

53. To print the natural numbers till ‘n’.

54. To print the whole numbers till ‘n’.

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.

59. To check a given number is prime or not.

60. To print the Prime Number series till ‘n’.

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’.

64. To find the sum of following series 1+2+4+8+……+n.

65. To Evaluate the following series: 1+x+x2+x3+…..+xn.

66. To evaluate the following series: 1+x+x2/2+x3/3+…..+xn/n.

67. To evaluate the following series: 1-x+x2-x3+x4-x5…..+xn.

68. To find the sum of the series [ 1-X^2/2!+X^4/4!- .........].

69. To Compute the Sin series.

70. To Compute the Cos series.

71. To find the power of a given number without using inbuilt function pow ( ).

72. To Split number into digits.

73. To print the factors of a given number and total numbers of factor.

74. To find the sum of digits of a given number.

75. To find the sum of digits of a given number till the resulting number is a single digit.

76. To find the sum of squares of digits in a given number.

77. To find the reverse of a given number.

78. To check the given number is palindrome or not.

79. To count the number of digits in a given number.

80. To find the frequency of a digit in a given number.

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.).

82. To find the factorial of a given number.

83. Convert a decimal number to binary number.

84. To find the GCD and LCM of two input numbers.

85. To print First n terms of Fibonacci Numbers.

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

87. To Check a given number is Armstrong number or not.

88. To display the Tables for input ‘n’.(2*1=2……. 2*20=40).

89. To print nth Fibonacci number.

90. To find square root of a given number without using square root function.

91. To print the sequence of prime numbers between two intervals

92. To find largest, smallest and second largest of three numbers.

93. To Find HCF of two Numbers.

94. To Display Armstrong Numbers between Two Intervals.

95. To check given number is strong number or not.

96. To display the multiplication table.

97. To print Floyd’s triangle.

98. To print Pascal triangle.

99. To print pyramids of numbers.

100. To print the following patterns:

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.

102. To find out prime factor of given number.

103. To compute the NCR.

104. To print 1 to 100 without using loop.

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

is 1+1+2+4=8 and the product of its digits is 1*1*2*4=8.)

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

happy number because {1^{2}+3^{2}=10}, and {1^{2}+0^{2}=1}.)

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

=16 is a perfect square number.)

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

which contains all digits from 1 to 9).

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

appears at the end of its cube. Ex: 5 - 5*5*5=125).

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

number that has an even number of 1s in its binary expansion).

115. Generate the random numbers between the given interval.

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

dividend is 12. (10+2)

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

14 as the perfect dividend and then 21 as the next dividend.)

Arrays:

118. To read a 1D - array with n elements and to print the same.

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.

121. To generate the Fibonacci series using arrays.

122. To find the sum of odd elements and even elements stored in an array.
8
Problem Solving and Programming

123. To print the twin primes up to specified limit.

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.

126. To convert the decimal value to binary value.

127. To convert the binary value to decimal value.

128. To find the smallest and largest element in the array.

129. To evaluate the Polynomial using a0x0+a1x1+a2x2+….+anxn Horner’s method.

130. To swap the content of two arrays.

131. To compute the following:

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.

135. To read a 2D - array with m * n elements and to print the same.

136. To copy one 2D – array in to another 2D – array.

137. To find the sum of all the elements in 2D – array with m*n size.

138. To find the largest element in the 2D - array.

9
Problem Solving and Programming

139. To perform the matrix Addition.

140. To perform the matrix Subtraction.

141. To perform the matrix Multiplication.

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.

144. To find the Norm of the matrix.

145. To find the Transpose of the matrix.

146. To check a given matrix is Scalar matrix or not.

Strings:

147. To count vowels and consonants in a input string.

148. To check whether the string is palindrome or not.

149. To convert lower to upper and upper to lower

150. To count a character in given string.

151. To perform a binary search for array of strings

152. Convert a given integer array of Size “N” into string.

153. Program to reverse the words in a string.

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

157. To print duplicate characters from the string.

158. To check if two strings are anagrams of each other.

159. To convert string to integer.

160. To count the number of words in a given string sentence.

***** Programming is Fun...., Let’s have the Fun......In Coding......*****

10

You might also like