You are on page 1of 2

School of Computer Science and Engineering

Fall Semester – 2021-2022


CSE1007-Java Programming
FAT Lab Exam – L51+L52
Date: 9/12/2021 Marks:50

1. A. Create an interface Hailstone with a method displaysequence(int), even(int), odd(int).


Write a Number class that implements the interface to display the Hailstone sequence for
a given number. Also display the total count of numbers in the sequence.
For any number it's possible to make a sequence of numbers that will eventually end in one
by following a simple rule; if the number is even halve it by two, if it's odd multiply it by
three and add one (e.g., starting with the number 5 the sequence would be 5 16 8 4 2 1).

b. Create a class LenthySeq with an array that stores the length of the hailstone seq for
numbers from 1 to 100. Identify the lengthiest hailstone sequence by inheriting the Number
class.

c. Create a LinkedList to add each number in a sequence to the end of the list. Display the
linked list in both forward and reverse order.

2. Create database of the student with the details such as (name, registernumber, cgpa, age,
dayscholar/hosteller).
Create a class student with the needed attributes. Use array of objects to store ‘n’ number
of students’ details into the database.
Write a java program to fetch the following details from the database.
a. List of students whose joined in 2018.
b. List of students whose age is between 18-20
c. List of students with CGPA less than 5.
d. List of students who stay in hostel.
e. List of 2019 batch students who are dayscholars.

3. a. Create a file for storing the book details as objects [booknum (int), name (String),
price (float), stack/reference (char), textbook (Boolean)] read from the user. Write a java
program to read the file and
b. Write a search function to search for a book with booknum or name. Raise an
Exception if the book details are not found.
c. Write a method sort to display the book details in sorted order with respect to price.
d. Write a method Extract to textbooks and reference books separately in 2 separate set.

4. Assume husband and wife have a joint account in the bank. An amount of Rs.25000 is
credited to the account as salary. They do shopping individually with the same account.
Synchronize the shopping of both such that the balance in the account does not go below
5000. If the shopping expense reaches the base limit. Raise an exception to both.

You might also like