Practical Exercise1
Practical Exercise1
Question1
Write a program for a bank accountant to calculate the interests, which customers will gain on
investing any amount of money for any given period of time. (Hint: Keep the rate of interest
as fixed.)
Question2
Howell University is an accredited European university, which offers a range of courses to its
students. It strives to give students the very best in terms of education and course content.
Now the university management is introducing a new IQ testing system for its MBA
students, which is an add-on to the traditional Examination System. This tests the IQ of the
students by testing them on four different subjects like Aptitude, English, Mathematics and
General Knowledge.
Consider yourself to be a part of the software development team that is supposed to design
the application in Java. First the application asks the student the number of attempt. If
student responds with a value higher than 1, then the application terminates and displays a
corresponding message. However, if the student is attempting the test for the first time, it
displays the following menu:
1. Aptitude
2. English
3. Math
4. GK
5. Exit
On entering a value between 1 and 4, the application displays the corresponding question.
Note that the student can attempt only once for each subject listed. When a student enters
the correct answer for the question, the score for that subject gets incremented by 10
points. Once the student appears the test for all the subjects, he/she can choose to exit the
application. After selecting the Exit option, the student can get the total marks printed on
the screen. The total scores should be calculated by adding up all the individual scores in
each subject. Next the application displays the following based on the score:
Bonus points earned
Total score out of 50
Message on IQ level
The application displays the bonus points based on the following conditions:
1. No bonus point is given, when the total score equals to 10.
2. A bonus of 2 points is given, when the total score equals to 20.
3. A bonus of 5 points is given, when the total score equals to 30.
4. A bonus of 10 points is given, when the total score equals to 40.
The message on IQ level is displayed on the basis of following conditions:
1. If the final score equals 10, then a message is printed saying Your IQ level
is below average".
2. If the final score equals 22, then a message is printed saying Your IQ level
Question 3
United Bank is an esteemed bank that provides banking services for profit. Its services
include receiving deposits of money, lending money and processing transactions. The
management of United Bank is looking at automation as a means to save time and effort
required in their work. In order to achieve this, the management has planned to
computerize the following transactions:
Deposit money in an account
Withdraw money from an account
The United Bank Manager and a team of experts have chosen your company to provide a
solution for the same. Consider yourself to be a part of the team that implements the
solution for designing the application.
Create an application using Classes and Objects to implement the transactions. The
application should consist of the following classes:
1. Account.java
2. AccountTest.java
Each file has a specific purpose and functionality. The descriptions of each file are as
follows.
Account.java
The Account class is used to store the details of the procedures followed in the bank such as
depositing money to the account and withdrawing money from the account.
The Account class contains instance variables amount and balance to store the actual
amount and the balance amount respectively.
Create a method named deposit() to allow the user to deposit some amount in his
account. This method should check whether the amount to be deposited in the account is
more than zero; otherwise display appropriate message.
Similarly, create a method named withdraw() to allow the user to amount from his
account. This method should check whether the amount to be withdrawn is not more than
the current available amount in the account; otherwise display appropriate message.
Finally, create a method getBalance() to return the balance in the account.
AccountTest.java.
The AccountTest class demonstrates the use of class, methods and objects in addition to
displaying a menu with options of depositing cash, withdrawing cash and quitting the
application.
Question 4
The CD House has the most complete collection of Different audio and video CDs, with over
700 individual titles. Now the company wants to introduce automation system to manage
the existing and newly added CDs. Consider you to be a part of the team that implements
the solution for designing the application.
Create an application in Java, which can be used to manage the CD catalog in real time by
adding new CDs with all the details captured, searching for existing CDs, displaying the
entire catalog with all the details. The application initially displays a menu with the following
options.
1.
2.
3.
4.
Implement the main menu which will display the above list of choices to navigate through
the CD catalog. When the user selects an option the corresponding function must be called.
The application terminates by printing an appropriate message and showing the
corresponding result, when the user chooses to exit the application.
When a user enters the first choice to Add CD, the application checks for space in the
array of CDs. If there is place in the array, it starts accepting all the details of the CD one
after the other. Otherwise it prints a message saying unable to add CD. The details of the
Player.java
Tax.java
PlayerIncome.java
GradeBonus.java
TournamentIncome.java
PlayerTest.java
Each file has a specific purpose and functionality. The descriptions of each file are as
follows:
Player.java
The Player class is an abstract base class that contains an instance variable to store the
name of the Player, and an abstract method.
The Booking class should contain an instance variable name to store the players name.
An abstract method named displayDetails() is created to display the name of the player.
Tax.java
An interface named Tax should be created that will act as an interface to calculate the tax
of the players income.
Declare and initialize a constant variable TAX_PERCENT to store the tax percentage. Also
create an abstract method named calculateTax() to calculate the tax.
PlayerIncome.java
The Player Income class should be a derived class of class Player and implement the
interface Tax. This class should be used to store the Player details and display the same.