0% found this document useful (0 votes)
6 views

Dms - 6703462876aa8JAVA LAB ASSIGNMENT-5 (Array of Objects, Static, Nested Class, Command Line Argument)

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)
6 views

Dms - 6703462876aa8JAVA LAB ASSIGNMENT-5 (Array of Objects, Static, Nested Class, Command Line Argument)

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/ 2

Assignment-5(Array of objects, static, nested class, command line argument)

Sl. No. Question

Define a class Employee with the following members:


Data members: private String empName
private String empNo
private int dependentCnt

1 Methods:Employee(String name, String eno, int depcnt): constructor


void showEmpDetails():displays empNo and empName
intdepCount(): returns dependentCnt
Write a separate class called EmpTest with a main method that define an array of n employees
where the value of n will be inputted from the user. Read and store the information of all n
employees. Display the details of the employees with more than two dependents.

Create a class Account having data members accNo, balance, timePeriod and intInYears(as static
and initialize with 7.5%). The class should also contain the following methods:
● float calculateInterst() which calculates and returns the interest amount.
● void showAccDetails() which displays account number, balance and calculated interest
2 amount.
● static void changeIntRate(float newRate) which changes the interest rate to newRate.
Create an array of object of the class Account. Store the details of each object through the
parameterized constructor. Display all the account details by calling the method
showAccDetails().Change the interest rate to a new one by calling the method changeIntRate().
Finally display the account details after the change in interest rate.

Create a class Student having data members name, roll and address. Note that address is an object of
inner class Address having data members city and pin. Create some student class objects. Read,
3 store (using constructor) and display their information. While creating the objects your program
should display a message “Creating student number n” from the constructor. You can get the value
of n by using a static member of Student class which is initialized to 0.

Write a program that will take two integer numbers from the command prompt and find their GCD
4 and LCM. If the user does not provide exactly two numbers of arguments then the program should
display error message.

5 Write a Java program to find frequency of each digit in a given integer.

Write a Java program to define a class Student having the attributes: sName, sRollno, sBranch and
CGPA. Define default and parameterized constructors for the above class. Write a method which
6
will display the student details. Read and display the details of 5 students using an array of Student
class object.

Write a java program to define a class Employee with data members empId, empName and
designation. Define a constructor to initialize the members of the class. The class should also have a
7
method to display the employee details. Read and display the details of 5 employees using an array
of Employee class object.

8 Define a class Calculator with the following methods: A static method called powerInt(int num1, int
num2), This method should return num1 to the power num2. A static method called

1
powerDouble(double num1, int num2). This method should return num1 to the power
num2. Invoke both the methods and test the functionalities. Hint: Use Math.pow(double,double) to
calculate the power.

You might also like