BJP Assignment 1
BJP Assignment 1
IBRAHIMBAGH, HYDERABAD-31
Department of Computer Science and Engineering
Name of the Course: Basics of Java Programming
Assignment – I
Q. BTL Mapped
Description of the question Marks
No. (1/2/3/4/5/6) CO PO
WAJP to create a class ‘Student’, overload the
constructors depending on the student is final year or
not, if yes take a parameter companyName, else skip
this parameter. Also, overload a method Eligible(),
taking attendance, other overloaded method having
attendance and Internal marks percentage as 2 3 2 1,2,3
1
parameters. Also define a method calcCGPA()
which takes Student object as a parameter/’this’, also
sendDetails() that returns the student object. Use
‘this’ keyword to handle the instance variable hiding
and constructor chaining/reusing.
Write a program to perform the following functions
using classes, objects & methods
i) Read 5 subjects marks of 5 students 1 3 1 1,2
2
ii) Calculate the percentage and print the result
on the screen
WAJP to create a class ‘Student’, overload the
constructors depending on the student is final year
or not, if yes take a parameter companyName, else
skip this parameter. Also, overload a method
Eligible(), taking attendance, other overloaded
method having attendance and Internal marks
percentage as parameters. Also define a method 2 3 1 1,2
3
calcCGPA() which takes Student object as a
parameter/’this’, also sendDetails() that returns the
student object. Use ‘this’ keyword to handle the
instance variable hiding and constructor
chaining/reusing.
Set-2
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Create a class Employee with calc_salary() as one of
the methods with appropriate members. Write a
program to create two types of employee,
1 2 3 2 1,2
permanent_ emp and hourly_ emp, and override
calc_salary() function in both.
Set-3
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Create a Student class inheriting Person class. Write
the program code for StudentApp.java that creates
several Student objects and displays all information
about each student in the command window. The
Person class should have static variables called
1 percentMales and percentFemales with a static 2 3 1 1,2,3
method that computes these values. After the
application displays the student information, it
should also display the percentage of males and
females
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Create a class Faculty that inherits from Person with
a new instance variable called title that hold values
such as “Assistant Professor”, “Associate Professor”,
or “Professor” include a constructor and set and get
1 methods for title. Write a program called 2 3 2 1,2,3
FacultyApp.java that asks the user to supply the
required information for a Faculty object and then
instantiates the Faculty object. Compile and test the
application.
To read the details of a student like name, Write a
2 java program to sort given list of integers in 1 3 1 1,2
ascending order.
Define a class MotorVehicle as described below.
Data members:
(a) modelName (b) modelNumber (c)
modelPrice
Methods:
(a)display() method to display the name, price,
and model number.
Define another class named Car that inherits the
class MotorVehicle and has the following:
3 Data Members: 2 3 2 1,2
(a) discountRate
Methods:
(a) display() method to display the Car
name, Car model number, Car price and
the discount rate.
(b) Discount() method to compute the
discount.
Create the Objects of MotorVehicle and Car with
suitable constructors and test it.
Set-5
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Create a Student class inheriting Person class. Write
the program code for StudentApp.java that creates
several Student objects and displays all information
about each student in the command window. The
Person class should have static variables called
1 percentMales and percentFemales with a static 2 3 2 1,2,3
method that computes these values. After the
application displays the student information, it
should also display the percentage of males and
females
WAJP to Create a class named as 2DShapes, that
contains an method named numberOfEdges(). Define
a Polygon sub-class, with having area as overridden
method to its sub-classes named, Triangle,
Quadrilateral, such that each one of the classes
overrides the method numberOfSides() and area, that
2 1 3 1 1,2
contains the number of sides in the given geometrical
figure, Now create sub-classes called Rectangle and
Parallelogram for class Quadrilateral, with
respective members. Also compute the area of each
shape, by overriding the methods wherever possible.
Set-6
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Create two files, Undergraduate.java and
Graduate.java that contain the classes Undergraduate
and Graduate, respectively. These classes both inherit
from the Student class. The Undergraduate student
has an instance variable collegeClass, and the
1 Graduate student has an instance variable called 2 3 2 1,2,3
undergradDegree. Include toString methods for both
kinds of students). Create a program called
StudentApp2.java that creates specific undergraduate
and graduate students, using toString methods to
display all information about the students.
Create a Circle class with required instance variables
and the following methods:
(a) circleCircumferencce() – compute the
circumference of a circle.
(b) arcLength() – compute the length of the arc
2 1 3 1 1,2
for a given angle.
Within the main() method of the class named Circle,
create an object of the class Circle. Compute it
circumference by accepting the radius and arc length
by accepting the angle from the keyboard.
3 Create a class named Employee with the 2 3 1 1,2
following details:
Data members:
(a) name (b) address (c) age (d) gender
Method:
(a) display() to show the employee details
Create another class FullTimeEmployee that
inherits the Employee class:
Data members:
(a) salary
(b) designation
Method:
(a) display() to show the salary and
designation along with the other employee
details
Create another class PartTimeEmployee that
inherits the Employee class:
Data members:
(a) workingHours
(b) ratePerHour
Methods:
(a) calculatePay() to calculate the amount
payable
(b) display() to show the amount payable
along with other employee details
Create objects of these classes and call their
methods. User appropriate constrcutors.
Set-7
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
To overload a method area() which computes the
area of a geometrical figure based on number of
parameters. If number of parameters is 1 and is of
type float it should calculate the area of circle, if it is
1 of type int it should calculate area of square. If the 2 3 2 1,2,3
number of parameters is 2 and they are of type float
calculate area of triangle, if they are of int calculate
area of rectangle.
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Software is being developed by a university that
displays SGPA of your current semester. You are
given the task to develop a module that calculates the
SGPA with respect to the secured grade points
1 corresponding to given number of credits in each 2 3 1 1,2,3
subject. The credits for the courses are: Graphics: 2,
PPS: 4, JAVA: 3, Chemistry: 3, English: 2, Technical
Skills: 1.5, Data Structures: 4. Complete your
Module by displaying the SGPA of current semester.
Create a program called AverageTestScore.java. Ask
the user the number of students for which test scores
are to be entered. Then, for each student, the user
should enter the name of the student. The program
should then ask how many test scores are to be
entered for that student (the number of test scores
may be different for each student). The student
2 1 3 1 1,2
names should be stored in an array, and the test
scores for each student should also be stored in an
array. The program should display the name of each
student, the number of test scores for that student,
and the average test score (formatted to one decimal
place) for that student, with each student’s data in
one line of output.
Create a class called Vehicle in Vehicle.java
with instance variables make (such as Ford, GM,
Chrysler, Toyota or Honda), year and
horsepower (200,300, and 400). Add the
necessary constructor and set and get methods.
Then create classes Bus and Truck in program
files Bus.java and Truck.java respectively. Bus
has an instance variable called numOfPassengers
3 2 3 2 1,2
(1 to 50) and Truck has an instance variable
called towingCapacity(0.5,1.0,2.0 or 3.0 tons).
Both Bus and Truck inherit from Vehicle and
contain their own toString methods for
displaying all their attributes. Compile all three
classes. Create the Objects of Bus and Truck classes,
accept and display their details with the help of the
methods using dynamic polymorphism.
Set-9
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
Software is being developed by a university that
displays SGPA of your current semester.
You are given the task to develop a module that
calculates the SGPA with respect to the
secured grade points corresponding to given number
of credits in each subject. The
1 2 3 1 1,2,3
credits for the courses are: Graphics: 2, PPS: 4,
JAVA: 3, Chemistry: 3, English: 2, Technical Skills:
1.5, Data Structures: 4
Complete your Module by displaying the SGPA of
current semester.
Set-10
BTL Mapped
Q.No. Description of the question Marks
(1/2/3/4/5/6) CO PO
1 WAJP to create a class Bank, with details like IFSC 2 3 1 1,2,3
code, Branch code, Bank name, and display(). Create
a subclass Account with members CustomerName,
AccountNumber, Joint/single account, and other
espective instance methods. Account can be Savings
or Loan Account create those sub-classes. The
required members for the SavingsAcc are
balance,withdraw(), deposit(), getIntersetRate(),
addInterest() and any other. For LoanAcc class the
needed members may be InitialLoaAmt (principle),
AnnualInteresrRate, NoofYeearsRepayment, with
instance methods as getMonthlyIR(),
gerMonthlyPaymentAmount(), getTotalPayment().
Create a CarLoan subclass with one of the member
as downPayment.
Note: