Download - Term End Mon1
-
8/6/2019 Term End Mon1
1/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program number 1JAVA 1
Write a java Applet program that allows you to enter any number of words in text area.The program should count the occurrences of every vowel in the text entered, when a
count button is clicked. The count should be displayed in individual text fields.
Count
Occurrences of:
A
E
I
O
U
-
8/6/2019 Term End Mon1
2/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 2
Java
Write a Java Applet that allows you to enter marks and find average marks. "Separatingsymbol between marks" indicates the character that seperates marks entered in the
textarea.(67,78,90). "Auto-determine marks" is a way for the program to automaticallydetect how many marks have been entered.
Number of marks:
Auto-determine number of marks?
Separating symbol between marks:
Submit Query
Average of marks:
-
8/6/2019 Term End Mon1
3/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 3
JAVA
Write a java program that counts the number of occurrences of a given word in a given
text passage.
Search for:
Case insensitive?Submit Query
Occurrences:
-
8/6/2019 Term End Mon1
4/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 4
JAVA
Write a java program to implement the following.Create two threads MaxFinderThread, SortDescendThread for MainThread.The
MainThread populates an integer array with data. The SortDescendThread sorts the array
in descending order.MaxFinderThread finds the maximum element in the array using thevalue obtained after SortDescend Thread.See to that mutual exclusion is conformed.
-
8/6/2019 Term End Mon1
5/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 5
Java
Write a java applet to implement the following.
What is your preferred server side coding language?
ASP / VB
Perl
PHP
java
Vote
Also include button result.When the result button is clicked,the result is displayed on
Textarea.
-
8/6/2019 Term End Mon1
6/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
JAVA
Given a classClass Student
{private int regno;
private string name;
private mark[];public Student () { }
public Student (int n) {}
public void get ();
}
Create the class in java.get 10 student objects.Write the student objects into filestud.dat and close the file. Open the file for reading, read the student objects, find the
total and average.display the student details along with total and average on to the screen.
-
8/6/2019 Term End Mon1
7/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Write a Java Program to implement the following
Write characters (strictly alphabets) into a file old.txt.
Open file old.txt, read the file from backwards (usage of getFilePointer () is
must) offset the character read by 1. Store the contents into file new.txt. Read new.txt to get back the original content,i.e the content written in old.txt
-
8/6/2019 Term End Mon1
8/22
VITU N I V E R S I T Y(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
JAVA
Create a applet that takes an expression in a text field.On clicking the calculate button
Computes the result of the expression and displays it in another textfield which is not
editable.
Example Text Field
Enter Your expression:2 + 3 * 9
Calculate
Result of your expression:45
-
8/6/2019 Term End Mon1
9/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 8JAVA
The swipe card system produces a text file for each day of the week. It contains the name,
course and matriculation number of each student t hat has attended the lecture on that
day. (There is onlyone per day!). There are no duplicates. For example we might have thefile mon.txt with:
John
Computing123
Ken
Mathematics234
etc.
Develop a program that inputs data from each of the five files (mon.txt, tue.txt, wed.txt,
thurs.txt, fri.txt) and produces a report that shows:Each students details and the number of lectures attended during the week
-
8/6/2019 Term End Mon1
10/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 9
Create a Two threads WriterThread,ReaderThread for the MainThread.TheWriterThreads writes the contents into a file and ReaderThread reads the contents from
the file.ReaderThread is made to wait until the writer writes contents into file.Mutual
Exclusion should strictly be enforced.
-
8/6/2019 Term End Mon1
11/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, IndiaSchool of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 10
Create an applet that takes the contents as when it is entered in a text field, reverses thecontents and stores it in textarea.Implement appropriate listeners to listen to the
event.Include a clear button in applet to clear the text field and textarea.The textfield
should accept only alphabets.
-
8/6/2019 Term End Mon1
12/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 11
Consider the following interface
interface train
{int firstclass=10;
int secondclass=10;
int RAC=5;int reserve(int type,int no_of_seats);
int cancel(int type,int no_of_seats);
}Write the definition of the class which has to implement the train interface. While
reserving adjust the number of seats for corresponding type if it has not reached
maximum limit, else put it in RAC and while cancelling increment the count of
RAC. Add necessary methods and variables in the class.
-
8/6/2019 Term End Mon1
13/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 12
DrawaString(VITUNIVERSITY)inAppletwindowandmovetheStringfromtop
to bottomofthewindowcontinuously-useAppletclass.
-
8/6/2019 Term End Mon1
14/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java LabDuration: 2 hrs Max Marks:50
Program Number 13
Create an abstract class Bank that contains withdraw and deposit methods. Create
class savings account from Bank. Use a static variable annual_interest_rate to store
the annual interest rate for all account holders. Each object of the class contains a
private instance variable balance, account number and name of the customer. Provide
a method to calculate monthly interest. (Interest= balance*annual_interest_rate/12,
add this to balance.). Create a method to modify the annual_interest_rate. Create two
objects of savings account and call all the methods available in that class.
-
8/6/2019 Term End Mon1
15/22
VITU N I V E R S I T Y(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 14
Create an interface for queue operations. Implement the interface as fixed queue andgrowable queue. Try to apply atleast one instance variable in the interface.
-
8/6/2019 Term End Mon1
16/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, IndiaSchool of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program Number 15
Implement the class hierarchy given below and use dynamic method dispatch to test theworking of all classes.
Shape
area( ) : double
perimeter():double
Rectangle
width,height: double
area( ) : double
perimeter( ) : double
Circle
radius : double
area( ) : doubleperimeter( ): double
diameter( ) : double
Square
-
8/6/2019 Term End Mon1
17/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program 16
Given a class definition
class Node{
int item;
Node next;
}
public class StackOfInts
{
private Node top;
public void push (int N)
public int pop ()
public boolean isEmpty () {
}An object of type Node holds one of the items in the linked list.
Top is the reference to the Node that is at the top ofthe stack. If top == null, then the
stack is empty.If the stack is empty throw an exception IlegalStateException, stating that
pop is not possible from an empty stack. Write a JAVA program to implement thefollowing.
-
8/6/2019 Term End Mon1
18/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, IndiaSchool of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program 17
A common programming task is computing statistics of a set of numbers. (A statisticis a number that summarizes some property of a set of data.) Common statistics
include the mean (also known as the average) and the standard deviation (which tells
how spread out the data is from the mean). Create a class called StatCalc that can be
used to compute these statistics, as well as the sum of the items in the dataset and the
number of items in the dataset.the StatCalc class has count ,sum ,numArr[] and
SquareSum as its data member If calc is a variable of type StatCalc, then the
following methods are defined:
o StatCalc(int size)
o
calc.enter (item);where item is a number, adds the item to the dataset.o calc.getCount () is a function that returns the number of items that have
been added to the dataset.
o calc.getSum () is a function that returns the sum of all the items that havebeen added to the dataset.
o calc.getMean () is a function that returns the average of all the items.
o calc.getStandardDeviation()
create a subclass StatCalc WithMinMax that has two datamembers max andmin.The class also has getMax() , getMin() to find the greatest and least of all
the numbers.use the constructor of base class to initialize the base class
members.Your program should have handled all exceptions.
-
8/6/2019 Term End Mon1
19/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, IndiaSchool of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program 18
Create a class Account with following attributes and methods :-owner , balance_amount,
init() , deposit(), withdraw() and print().The account has parameterized constructor toinitialize values apart from init().A specialist sub-class called GoldAccount.
This new type account permits the owner to withdraw money up to a credit limit and thus
have a negative balance. (The basic Account only allows the balance to drop to zero).
Note:-
a. The Gold Account class has a new attribute called creditLimit
b. The GoldAccount has a parameterized constructor to initialize the values (base
constructor should be called to initialize the inherited attributes.c. The GoldAccount has a new method called setCreditLimit ()
d. The GoldAccount has methods to override the withdraw () and print () methods
e. The GoldAccount inherits the attributes owner and balance from Account
f. The GoldAccount inherits methods initialise () and deposit () from Account
Create two instances of both Account and Goldaccount class each. Initialize the oneinstance using constructor and the other one using init ().Write a main program that does
all operations on both the classes. Throw appropriate exceptions wherever possible.
-
8/6/2019 Term End Mon1
20/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, IndiaSchool of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program 19
Design a check writing systems to prevent alteration of check amount. One common
security method requires that the check amount be written in numbers and spelled out in
words. Write a Java application to implement this system. (Example for 99678 ninetynine thousand six hundred and seventy eight only).[Use String or StringBuffer where
ever necessary.]
-
8/6/2019 Term End Mon1
21/22
VITU N I V E R S I T Y(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, India
School of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program 20Consider an object-oriented design for the following problem. You need to store
information for bank accounts. For purposes of the problem, assume that you only need
to store the current balance, and the total number of transactions for each account. The
goal for the problem is to avoid duplicating code between the three types of account. An
account needs to respond to the following methods:
i. Constructor or Init message
ii. Initialize a new account
iii. void Deposit(float amt)
- add the amt to the balance and increment the number of transactions
iv. void Withdraw(float amt)
- subtract the amt to the balance and increment the number of transactions
v. float Balance();
- return the current balance
There are three types of account: (Derive three classes from bank account)
Savings:: deposit and withdraw just affect the balance.
Recurring Deposit: No withdrawal in-between the fixed time. Makes compound interest
+ investment at the end stated period.
Loan Account: Initializes an account with a negative balance (Loan obtained.) and rate of
interest. No withdrawal allowed. Deposit at every month will go for interest (interest for
that months balance) and the balance is updated by reducing the remaining amount.
-
8/6/2019 Term End Mon1
22/22
VITU N I V E R S I T Y
(Estd. u/s 3 of UGC Act 1956)
Vellore - 632 014, Tamil Nadu, IndiaSchool of Information Technology and Engineering
Term-End Lab Examination
B.Tech (IT) - IV Semester
Subject:Programming in Java Lab
Duration: 2 hrs Max Marks:50
Program 21
Java
Create a class below
Class Student
{private int regno;
private string name;
private mark [] ;( array of six)
public Student () { }public Student (int n) {}
public void get ();
}
Store the student objects in a vector.Display details about all the students by
iterating/enumerating through the vector. Delete information about students who havefailed in more than one subject.Display the information about 3 toppers. (Menu driven
program is must)