Dms - 6703462876aa8JAVA LAB ASSIGNMENT-5 (Array of Objects, Static, Nested Class, Command Line Argument)
Dms - 6703462876aa8JAVA LAB ASSIGNMENT-5 (Array of Objects, Static, Nested Class, Command Line Argument)
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.
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.