Assignment (Object Oriented Programming)
Assignment (Object Oriented Programming)
ASSIGNMENT
1. Mr. Obi Okoye runs a Thrift and Loan business (Alajo), where his customers can deposit
money daily or weekly or monthly. Customers can obtain Loan with interest calculated
depending on his/her total deposit (capital) and mode of contribution (daily, weekly or
monthly). The conditions for granting loans are:
- customer must have been a depositor for more than 3 months
- total loan approved cannot be more than his/her capital, depending on mode of contribution:
Daily = up to 100% of capital with interest of 2%
Weekly = up to 85% of capital with interest of 5%
Monthly = up to 60% of capital with interest of 7%
Write a java program that accepts customers name, his capital (total deposit), amount requested
as loan and mode of contribution, period of contribution from the keyboard and determines
his/her eligibility for loan and the appropriate amount to be disbursed to him and the interest he
will be paying.
2. (a) In OOD association between objects can be represented in two types: ------- and ---------
(b) Given an object ‘House’ create two separate diagrams showing the stronger and weaker
association among components (objects) that are part of the object ‘House’
(c) Explain briefly the benefits of OOP
(d) write down a general template for a Class definition in OOP
3. Write a Java program that computes the sum of two matrices a and b and displays the result on the screen
a= 3 1 2 6 5 b= 8 2 4 6 9
6 2 5 6 2 2 3 5 3 6
5 3 9 4 8 4 3 6 8 2
1 2 4 2 7 6 7 4 5 2
(e) From (d) above, using FUTA as a case study, create a graphical representation of two object
classes representing students and lecturers in the institution.
5. Using the for and while constructs, write java programs that create a class called ‘LoopStructures’ that displays only
odd numbers from 1 to 1000, computes the sum and product of the odd numbers and display the values of the sum and
product of the numbers
6. (a) Let myString be a string given as: myString = “Object Oriented System”. Write a java
program that displays the content of myString in reverse order.
−b ± √ b −4 ac
2
(b) Given Quadratic formula x= , with the discriminant as d = b2 – 4ac, write a java
2a
program that
i. determines the nature of root of a quadratic equation (unequal, equal or imaginary)
ii. compute the roots X1 and x2 of the quadratic equation.
7. Create class named as A with variables int i = 5, int j = 10 and int k. create a method in class A that adds the values of i
and j and stores the result in k. Create a sub class B. Which is inherits from class A, and displays the sum of i and j and the
product of i, j and k.