Sie sind auf Seite 1von 11

tShri Vile Parle Kelvani Mandal’s

D. J. SANGHVI COLLEGE OF ENGINEERING


DEPARTMENT OF INFORMATION TECHNOLOGY
Semester: III
Subject: Java Programming Lab

1. WAP to open “notepad” using java application program

2. WAP to convert decimal number to hexadecimal

3. WAP in which a random number generated between 0-1000 is the cash inflow to the person
playing the game. Two people play the game 5 times and the winner is the one whose total
cash is maximum and the program displays the winner

4. WAP to generate 10 random numbers from 15-20 and find their mean

5. In a railway reservation system, a particular bogey is allocated for women passengers. The
bogey comprises of 72 seats. The 1st preference is given to female passengers whose age is
>=65. Passengers can provide their choice of seats that include lower, upper, middle, side
lower, side upper. WAP that allocates seats to the passengers according to their request. If
the number of requests exceeds the capacity of bogey it should give “reservation full”
message

6. WAP to find roots of a Quadratic equation. Take care of imaginary values.


No solution, if a, b are zero.
2
There is only one root if b -4ac=0
There are no real roots, if b2-4ac is negative
Otherwise there are two roots
7.

8. Write a program that reads any positive integer n and prints the digits in words. (For
example, if input is 1265 then output is one two six five).

9. WAP to find largest of 3 integers accepted form command line

10. WAP to accept a number from command line and print the sum of cube of individual digits

11. WAP to accept a number from command line and check whether it is Armstrong or not

12. WAP to generate the prime numbers between 1 and 100.

13. Write a program that reads a 4 digit integer and breaks it in a sequence of individual digits
[example: 1691 should be displayed as 1 6 9 1]

Prof. Stevina Correia Page 1


14. WAP pattern.java that takes an integer, N and prints a 2D N*N pattern with alternating
spaces and asterisks as follows:
*****
*****
*****
*****

15. WOOP in JAVA to find GCD and LCM of two non-negative numbers using EUCLID's
Algorithm

16. WAP to print the patterns


* * * * *
* * * *
* * *
* *
*
17. WAP to print the following pattern
*
* * *
* * * * *
* * *
*
18. WAP to print the following pattern
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1

19. Write a program to display following pattern using nested loops


A
A B A
AB C B A
ABC D C B A

20. Write a program to generate following pattern (N=3)


3
323
32123
323
3

21. Write a program to generate following pattern


0
101
21012
3210123

Prof. Stevina Correia Page 2


22. Write a program to generate following pattern
1
12
123
1234

23. Write a program to generate following pattern


****
***
**
*

24. WAP to print the sum of following series


1+1/2+1/3+......................+1/n
1-1/2+1/3-1/4+…………...1/n (take value of n from the user)
1+1/2^2+1/3^2+1/4^2……+1/n^n
1+1/x+1/x^2+…..+1/x^n

25. WAP in JAVA to compute the distance S fallen by an object in free-fall. The formula is
S=So+Vo*t+1/2*a*t*t
make a table of S for t=0,5,10.............100

26. WAP to accept 5 integers from user and sort in ascending order

1. WAP to find largest and second largest element of an array

WAP to check whether the entered 4 digit number is vampire or not. Combination of digits from this
number forms 2 digit number. When they are multiplied by each other we get the original number.
(1260=21*60)

27. Write a program for matrix addition

28.

29. The annual examination results of 5 students are tabulated as follows:

Roll No Subject1 Subject2 Subject3

Prof. Stevina Correia Page 3


WAP to read the data and determine the following
Total marks obtained by each student
The student who obtained the highest total marks

30. A record of average temperature is prepared for different cities month-wise as shown
below:
Month Jan Feb Mar … … Dec
State
State 1
State 2
….
State 5
WAP to read the data in 2D array and determine the following:
State with highest temperature recorded in the months of April and May
State with lowest temperature recorded in the months of December and January

31. WAP to find the binary form of a given number

32. WAP to insert an element into an array at the position specified by the user.

33. WAP in JAVA for fitting a straight line through a set of points (Xi,Yi) i=1,2,......n. The
straight line equation is y=mx+c and the values of m and c are given by...........................

34. Write the Menu driven program to perform


a) Addition of two matrices of order m*n and p*q
b) Multiplication of two matrices of order m*n and p*q
c) Transpose of matrix of order m*n
d) Addition of diagonal and non-diagonal elements

35. WAP to find out number of uppercase & lowercase characters, blank spaces and digits from
the string

36. WAP to capitalize the first character of each words from a given sentence (example:all the
best All The Best)

37. Write a program to accept any string up to 15 characters. Display the elements of string
with their element nos. use toCharArray () function.

38. WAP to check if a string is a palindrome or not

39. WAP in which user is asked to enter any 4 words through command Line. These words are
sorted and then displayed

40. WAP to count the frequency of occurrence of a given character in a given line of text

41. Write a java program to demonstrate String Functions

42.

Prof. Stevina Correia Page 4


43. WAP to accept students name from command line and store them in vector

44. WAP to add n strings in a vector array. Input new string and check if it is present in the
vector. If present delete it else add to the vector

45. WAP to add the list of items using vector and delete an item in the list according to users
choice

46. WAP to read 5 names of students name from command line and store them in Vector. Sort
the list in alphabetical order and display using enumeration interface.

47. WAP that uses vector class to add 5 names initially. Display a menu:
Add new name
Delete name
Display name
Based on the choice entered by the user take appropriate action

48. WAP that accepts a shopping list of items and performs the following operations
Add an item at a specified location
Delete an item in the list
Print the contents of the vector

49.

50.

51. Write a java program to demonstrate Array and Vectors operations

52. WAP to accept a no. and compute the summation of digits recursively

Prof. Stevina Correia Page 5


53. WAP to find value of y using recursive function, where y=x^n.

54. WAP to calculate Fibonacci using recursion

55. WA recursive method to calculate factorial of an integer number

56. WAP to find volume of cube, cylinder and rectangle using function overloading

57. WAP in JAVA to find nCr and nPr

58. Write a menu driven Java program which read a number and should implement the
following methods
1. factorial()
2. reverse()
3. testArmstrong()
4. testPalindrome()
5. testPrime()
6. fibonacciSeries()

59. Write a Menu driven program in java to implement simple banking application. Application
should read the customer name, account number, initial balance, rate of interest, contact
number and address field etc. Application should have following methods.
1. createAccount()
2. deposit()
3. withdraw()
4. computeInterest()
5. displayBalance()

60. WAP to swap two numbers using call by value and call by reference

61. WAP to count the number of objects made of a particular class using static variable and
static method to display the same

62.

63. WA demonstrative program to illustrate nested class. Define a method in the inner class and
access the same by code outside the outer class(in a class with main())

64. Create a class Rectangle. The class has 2 attributes, length and width, each of which defaults
to 0. It has methods to calculate the perimeter and area of the rectangle. It has set and get
methods for both length and width. The set method should verify that length and width are
floating point numbers larger than 0.0 and less than 20.0

Prof. Stevina Correia Page 6


65. Create a class employee with data member’s empid, empname, designation and salary.
Write methods getemployee() to take user input, showgrade() to display grade of employee
based on salary, showemployee() to display details of employee

66. WOOP to arrange the names of students in descending order of their total marks, input data
consists of students details such as names, ID.no, marks of maths, physics, chemistry.(Use
array of objects)

67. write a program to read and display details of 10 employees with following specifications:
Data members: Emp_ID, Emp_name, Emp_Sal
Parametrised constructor: to initialise data members of Employee
Member function Display () to display information of all employees

68.

69. WAP to display area of square and rectangle using the concept of overloaded constructor

70.

71. Assume that a bank maintains two kinds of accounts for its customers. The saving account
provides compound interest and withdrawal facilities but no cheque book facility. The
current account provides cheque book facility but no interest. Current account holders
should also maintain a minimum balance and if the balance falls below this level, a service
charge is imposed. Create a class account that stores customer name, account number and
type of account. From this derive the class current account and savings account. Include
methods to achieve the following tasks
accept deposit from a customer and pdate the balance
display the balance
compute and deposit interest
permit withdrawal and update the balance
check for minimum balance, impose penalty if necessary and update the balance

Prof. Stevina Correia Page 7


72. Assume that the test results of a batch of students are stored in four different classes. Class
student stores the roll_number, class test stores the marks obtained in two semesters, class
sports stores the score obtained in sports and class result contains the total marks obtained
in the test and sports. The class test can inherit roll_number from student and the class result
can inherit the details of the marks and roll_number from test using multilevel inheritance.
Since multiple inheritances is not possible, class result can implement sports to obtain
sports marks. The relationship among these classes will be as implement sports to obtain
sports marks.

73. Consider a class network given. The class 'Admin' derives information from the class
'Account' which in turn derives information from the 'Person' class. WAP to display the
'Admin' object (use overriding)

Person

Name
Code

Admin
Account
Exp
Pay

74. WAP to display area of square and rectangle. Make use of interface to define templates of
methods to be there in the derived class

75. Design an interface with a method reversal. This method takes a string as input and
returns the reversed string. Create a class that implements the above interface

76. Design an interface with a reverse() that reverses the digits of the number

77. interface Matrix


{
final static int M=5,N=5; //matrix indices
void readMatrix(); //read a Matrix
void addMatrix(); //add two Matrix
void multMatrix(); //multiply two Matrix
void transposeMatrix(); //transpose of Matrix
}
Implement the above interface using a suitable JAVA class program and also develop the
main program

78. WAP to display volume of sphere and hemisphere using abstract classes

79. WAP to display area of square and triangle using the concept of abstract class

80. Write an abstract class program to calculate area of circle, rectangle and triangle

Prof. Stevina Correia Page 8


81. WAP to illustrate packages

82. WAP to demonstrate access protection in different packages

83. WAP to demonstrate Modules and Packages

84. WAP to accept and display month number. Throw NumberFormatException if improper
month number is entered

85. Write a Java program to identify whether inputted data is


byte/short/int/long/float/double/String/char type. (Use Exception Handling)

86. Make your exception class “InvalidMarks” which is thrown when marks obtained by
student exceeds 100

87. WAP that accepts the values of a, b, c and d. Calculate and display ((a+d) + (b*c))/ (b*d).
create user defined exception to display proper message when value of (b*d) is zero

88.

89. WAP that illustrates the output when a –ve number is passed as an argument for sqrt()
method (use exception handling)

90. Create a user defined exception CKECKARGUMENT to check the number of arguments
passed through command line. If the number of arguments is less than 5, throw the
exception else print addition of the five numbers

91. Write a java program to print first 20 prime numbers and 15 Fibonacci numbers by creating
two child threads and also print the total time taken by each thread for the execution.

92. Write java program to create the child thread. Comment on the execution of main and Child
Thread.

93. Write a program to print */*/*/*/*/*/*/*/*/*/ using two child threads. (hint:one thread
responsible for printing * and another for /)

94. WAP in Java to calculate Fibonacci series and Factorial of a number using two child threads

95. WAP to create multiple threads (one may display alphabets and other may display numbers)

96. WAP to illustrate use of isAlive(),sleep() and join() method.Create three classes A,B,C.
create another class "IsAliveJoin" to invoke isAlive() and join() methods for these 3 child
threads

Prof. Stevina Correia Page 9


97. WAP that evaluates square roots of 10000 numbers through 4 threads, each thread
processing 2500 numbers

98. WAP to create 3 threads and illustrate the working of synchronization. Two threads deposit
money into the account, whereas 3rd withdraws an amount from the account.

99. Write a JAVA applet to display "Hello JAVA"

100. Create an applet that displays “All the Best”

101. Write an applet to display the following

102. WAP to display the following menus and submenus

Menu demo
File Edit View
Undo
Cut
Copy
Paste

103. Write an applet to display the following

104. WAP to display a line, circle and arc inside the applet’s visible area

105. Write an applet to draw circle rectangle and line

106. WAP to check the font name and font size of string by passing parameter to applet

107. Write an applet to draw circle, rectangle and polygon.

108. Create a list of vegetables. If you click on one of the items of the list, the item should
be displayed in a textbox
109. WAP using AWT to create a simple calculator

Prof. Stevina Correia Page 10


110. WAP that converts temperature from Fahrenheit to Celsius. The Fahrenheit temperature
should be entered from keyboard via textfield. A textfield should be used to display the
converted temperature. (Celsius=5/9*( Fahrenheit-32)

111. Create 2 lists using JList class with a button. On click of that button. All selected items
in 1 list should be copied to another list

112. WAP to display string in different color in an applet. Also draw a filled hexagon in
orange color

113. WAP program to include 2 textfields to enter name and password. Set the echo character
to hide the password letters (uploaded on blackboard…login_awt.java)

114. WA applet program that allows user to choose items out of 6 checkboxes laid out in
default FlowLayout

115. WA applet program in which user is required to enter 1st name, last name and
qualification. On clicking submit button these details should be displayed

116. WA applet with 4 swing buttons with suitable texts on them. When the user presses a
button a message should appear in the label as to which button was pressed by the user

117. WA AWT program to create checkboxes for different courses belonging to a university
such that the course selected will be displayed

118. Create a frame having menubar and menuitems attached to it as follows:

Prof. Stevina Correia Page 11

Das könnte Ihnen auch gefallen