0% found this document useful (0 votes)
72 views22 pages

Term End Mon1

This document outlines 10 programming problems to be solved in Java for a term-end lab examination. The problems include writing programs to: 1. Count the occurrences of vowels in entered text. 2. Calculate the average of marks entered with a separating symbol. 3. Count the occurrences of a given word in entered text. The remaining problems involve additional Java concepts like threads, file I/O, applets, and string manipulation. Students are instructed to complete the programs within 2 hours and their work will be marked out of 50 points.

Uploaded by

Rohan Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views22 pages

Term End Mon1

This document outlines 10 programming problems to be solved in Java for a term-end lab examination. The problems include writing programs to: 1. Count the occurrences of vowels in entered text. 2. Calculate the average of marks entered with a separating symbol. 3. Count the occurrences of a given word in entered text. The remaining problems involve additional Java concepts like threads, file I/O, applets, and string manipulation. Students are instructed to complete the programs within 2 hours and their work will be marked out of 50 points.

Uploaded by

Rohan Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

VIT

UNIVERSITY
(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 1
JAVA 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
VIT
UNIVERSITY
(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. "Separating
symbol 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 automatically
detect how many marks have been entered.

Number of marks:
Auto-determine number of marks?
Separating symbol between marks:
Submit Query

Average of marks:
VIT
UNIVERSITY
(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:
Submit Query
Case insensitive?
Occurrences:
VIT
UNIVERSITY
(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 the
value obtained after SortDescend Thread.See to that mutual exclusion is conformed.
VIT
UNIVERSITY
(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.
VIT
UNIVERSITY
(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 class
Class 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 file
“stud.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.
VIT
UNIVERSITY
(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”
VIT
UNIVERSITY
(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


2+3*9
Enter Your expression:

Calculate

45
Result of your expression:
VIT
UNIVERSITY
(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 8
JAVA

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 the
file mon.txt with:
John
Computing
123
Ken
Mathematics
234
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 student’s details and the number of lectures attended during the week
VIT
UNIVERSITY
(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.The


WriterThreads 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.
VIT
UNIVERSITY
(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 10

Create an applet that takes the contents as when it is entered in a text field, reverses the
contents 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.
VIT
UNIVERSITY
(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.
VIT
UNIVERSITY
(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
Draw a String (“VIT UNIVERSITY”) in Applet window and move the String from top
to bottom of the window continuously-use Applet class.
VIT
UNIVERSITY
(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 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.
VIT
UNIVERSITY
(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 and
growable queue. Try to apply atleast one instance variable in the interface.
VIT
UNIVERSITY
(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 15

Implement the class hierarchy given below and use dynamic method dispatch to test the
working of all classes.

Shape

area( ) : double
perimeter():double

Rectangle Circle

width,height: double radius : double

area( ) : double area( ) : double


perimeter( ) : double perimeter( ): double
diameter( ) : double

Square
VIT
UNIVERSITY
(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 the
following.
VIT
UNIVERSITY
(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 17

A common programming task is computing statistics of a set of numbers. (A statistic


is 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 have
been 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 and
min.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.
VIT
UNIVERSITY
(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 18

Create a class Account with following attributes and methods :-owner , balance_amount,
init() , deposit(), withdraw() and print().The account has parameterized constructor to
initialize 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 one
instance 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.
VIT
UNIVERSITY
(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 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 ninety
nine thousand six hundred and seventy eight only).[Use String or StringBuffer where
ever necessary.]
VIT
UNIVERSITY
(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 20
Consider 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 month’s balance) and the balance is updated by reducing the remaining amount.
VIT
UNIVERSITY
(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 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 have
failed in more than one subject.Display the information about 3 toppers. (Menu driven
program is must)

You might also like