0% found this document useful (0 votes)
64 views8 pages

BJP Assignment 1

This document contains 6 sets of questions for a Java programming assignment. The questions involve creating classes to model real-world entities like students and employees, overloading methods, inheritance, polymorphism, and other core Java concepts. Students are asked to write code to create objects, define methods to calculate values like grades and salaries, and display the results. The assignment will help students practice and demonstrate their understanding of object-oriented programming principles in Java.

Uploaded by

PRIYANKA TATA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views8 pages

BJP Assignment 1

This document contains 6 sets of questions for a Java programming assignment. The questions involve creating classes to model real-world entities like students and employees, overloading methods, inheritance, polymorphism, and other core Java concepts. Students are asked to write code to create objects, define methods to calculate values like grades and salaries, and display the results. The assignment will help students practice and demonstrate their understanding of object-oriented programming principles in Java.

Uploaded by

PRIYANKA TATA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

VASAVI COLLEGE OF ENGINEERING (AUTONOMOUS)

IBRAHIMBAGH, HYDERABAD-31
Department of Computer Science and Engineering
Name of the Course: Basics of Java Programming
Assignment – I

Name of the Faculty: T. Priyanka Date of submission: 10/03/24


Class: B.E 3/4 OE-II Sem: IV
Academic Year: 2023-24
_____________________________________________________________________________
Set-1

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.

Create a java program called RemoveDuplicate.java


that asks the user to enter any number of integers.
The program should then display the unique elements
2 1 3 1 1,2
after eliminating the duplicates. The output should
include: the list of numbers entered by the user, and
the final results.
Create a class called Eligibility, to verify whether an
Indian is eligible to vote or not by considering age
3 and nationality. Also give a message to cast vote as 2 3 1 1,2
their right if eligible, else display appropriate
message.

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

Create a class Employee, program should initialize


data through constructors, using a separate
constructor for developer, hacker, tester and a
2 1 3 1 1,2
separate method to calculate their salary depending
on their designation, hire salary by 15% if appraisal
points are more than 4 out of 5.
WAJP to create a class with two methods-one 1 1,2
recursive method to find the gcd of a number using
3 Euclidean algorithm and another non-recursive 2 3
method to check given number is perfect or not, read
the input via parameterized constructor.
Set-4

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.

Write a program to create a class called Rectangle


which includes methods for the initialization of the
3 2 3 1 1,2
data members using method overloading, calculation
of the area and display the data members and area.

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.

Create a program called SellItems.java that presents a


menu to the user. Option 1 should allow the user to
enter any number of item prices. Option 2 should
2 allow the user to check out by adding the prices and 1 3 1 1,2
applying a 6% sales tax. The output should include a
list of the item prices, the subtotal of the prices, the
tax amount, and the final cost.
WAJP to create an account class. Define appropriate
constructor for this class. Define and implement
method to display account balance, deposit and
3 withdraw money. Show appropriate message if there 2 3 1 1,2,3
is an attempt to withdraw money which may lead to
account balance, less than minimum amount required
in account. Make necessary assumptions required.
Set-8

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.

WAJP to create a class Matrix, initialize the number


of rows and columns as zero, using a constructor, use
instance variables and methods to read rows and
2 1 3 1 1,2
columns, display the elements in the matrix, using a
default constructor.

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
3 2 3 2 1,2
percentage as parameters. Also define amethod
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-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:

 monthlyInterestRate = annualInterestRate / 12;


 monthlyPayment = loanAmount *
monthlyInterestRate / (1 -
(1 / Math.pow(1 + monthlyInterestRate,
numberOfYears * 12)))
WAJP to create an account class. Define appropriate
constructor for this class. Define and implement
method to display account balance, deposit and
2 withdraw money. Show appropriate message if there 1 3 1 1,2
is an attempt to withdraw money which may lead to
account balance, less than minimum amount required
in account. Make necessary assumptions required.
WAJP to Create a class Person with, Name, age and
display() as members, deriving a sub-class Student
with instance variables as rank, CollegeName,
phonenumber, rollNo, marks of 6 subjects and
overriding display method, print the basic details also
from super class display(), use the parent constructor
also to initialize the basic details of a person. For the
Student class create sub-classes named as UG and
3 PG, initialize the respective members using parent 2 3 2 1,2
constructor, display all the details of UG or PG
student by calling display () of super class, update the
phone number of student in the respective variable
inherited, and print the College phone number
available in student class using super and student
contact number also. Consider the class members as
needed.

You might also like