SCHOOL OF INFORMATION TECHNOLOGY AND ENGINEERING
Lab Assessment – III
Course Name: Java Programming Course Code: PMCA502L
Class Number : VL2023240106717 Slot: L19+L20
Date: 12 – Oct – 2023 Time: 9.30
Max Mark: 10
Instructions:
a. Do the coding and get the result through a simple editor and command
prompt. Should not use any IDE.
b. The answers must be of the same order of questions.
c. Prepare the document by copying the code as text (remove the extra line
space and paragraph phase)
d. Create a folder with your register number and store all your programs
there only.
e. Take screenshot of compilation(must) and the result for all programs
through “Snipping Tool”. The compilation and result should show that you
run the code from your folder. Include few cases if it is necessary to show
the quality of the code.
f. Finally, convert the document as a PDF and post it on VTOP- Lab DA-1 page
only, I couldn’t entertain different modes for submission as it is very hectic
for correction.
g. Upload your every week files in MOODLE for your future reference.
h. Late submissions will not be allowed.
1. Write a program in Java to raise exception for data validation and typo error. 2M
a. Read the Register Number and Mobile Number of a student. If the Register
Number does not contain exactly 9 characters or if the Mobile Number does not
contain exactly 10 characters, throw an IllegalArgumentException.
b. If the Mobile Number contains any character other than a digit, raise a
NumberFormatException.
c. If the Register Number contains any character other than digits and alphabets,
throw a NoSuchEl
2. Design an interface named as “bankprocess” which contains the signature for the
process “boolean withDraw(double amt)”. Create a class SavingsAccount and
CurrentAccount with accountId , Name and Balance as members. Define constructor to
initiate all members. Define a method called as void deposit(double Amt) which credits
the Amt into the account. Define another method void displayDetails() which prints
details of account. Both classes implement the interface “bankprocess”.
SavingsAccount should retain 5000 as min balance always. CurrentAccount allows
overdue of 10000 while debits amount from the account. So override the withDraw
method according to the account types and indicate withdraw process has done or not.
Design a test class to show the implementation of these. Get user input for account
details. Show output of various cases. 2M
3. Create a class GeometricObject which contains String color and Boolean filled. Define
methods getArea and getPerimeter. Restrict object creation for the GeometriObject
class. 2M
a. Design a class named Triangle that extends GeometricObject. The class
contains three double data fields named side1, side2, and side3. A constructor
that creates a triangle with the specified side1, side2, side3, its color and filled
detail.
b. Design a class named Rectangle that extends GeometricObject. The class
contains two double data fields named length and width. A constructor that
creates a rectangle with the specified length, width, color and filled detail.
c. Override getArea and getPerimeter according to the subclass requirements.
Define a democlass in Java which creates objects for subclasses and demonstrates all
methods.
Note: Area of triangle
Perimeter of triangle = a+b+c
Area of rectangle = l * w
Perimeter of triangle = 2(l+w)
4. Develop a package called CSE1007. Design two subpackages MathProcess and
StatProcess
a. MathProcess
i. Create a class ProductPerfectNumber. It has one integer as member.
Create a constructor with parameter. Design a method
isProductPerfectNumber() which verifies the parameter is a product
perfect number. A number is a product perfect number if the product of
all its divisors, other than the number itself, is equal to the number. For
example, 10 and 21 are product perfect numbers since 1*2*5 = 10 and
1*3*7 = 21
ii. Create a class FibonacciSeries with an integer member. Create a
parameterized constructor to initiate the integer. Design a method to
print Fibonacci series up to the member.
b. StatProcess
i. Create a class Mean with an array of integers and its size n as members.
Create a constructor to initiate the size of array. Design a method
getInput which gets ‘n’ integer numbers. Design another method
findMean which finds mean value of array of integers and return it.
ii. Create a class StandardDeviation with an array of integers and its size n
as members. Create a constructor to initiate the size of array. Design a
method getInput which gets ‘n’ integer numbers. Design another
method findStandardDeviation which finds standard deviation for array
of integers and return it.
Design a test program in java to import those packages and demonstrate the methods with
necessary class and objects. 3M