Institute of Business Administration (IBA)
CSE:142 Object Oriented Programming
Techniques
TASK #1 (10 marks)
Due Date: Monday, 1st November 2010, 08:00 am
Instructions:
Only softcopy is acceptable through email. In case of plagiarism, zero marks will be given to
those who are involved.
Questions
Write a Class ArrayManipulations and solve the following
questions. You may use superclass and subclass also. Also write
the driver class to check the results.
Q1 . Create three arrays of 5 elements each and input marks of two
midterms in both the arrays. Finally store the sum of elements of two
arrays in the third one.
Program Output:
MT-I MT-II Total
15 15 30
17 17 34
19 19 38
20 15 35
20 15 35
Q2. Input 5 number is an array and sort in ascending order and then
descending order.
Program Output:
Input any five numbers:
3
4
5
6
4
Sorted list in Ascending Order:
3
4
4
5
6
Sorted list in descending Order:
6
5
4
4
3
Q3. Create an inventory of product quantity in an array and update array
whenever any sale (by customer) or purchase (from
suppliers) occur.
Program output:
MobileCards = {"Ufone", "Warid", "Jazz", "Telenore"}
connection = {200,300,400,500}
Customer Purchase any card:
Card type: Ufone
Number of Cards: 20
update inventry
Ufone 180 cards left
Supplier sell any cary:
Card type: Ufone
Number of Cards 30
update inventory
Ufone 210 cards
Q4. Input names of 10 students in an array and find out if there exist any
duplicate name.
Program output:
Names of Student:
Arif
Amber
Zainab
Anum
Zain
Aneeka
Adnan
Imran
Fauz
Zainab
Anum
Arif
Duplicate Names are:
Zainab
Anum
Arif
Q5. Write a program that randomly fills a 3 by 4 by 6 array, then prints
the largest and smallest values in the array.
Q6. Write a method in ArrayManipulation Class that takes a single array
argument of elements of type double, and returns its cumulative sum by
iteratively adding the elements altogether. Computing the cumulative sum
of an array can also be done recursively by using, for example, the
following function prototype CumulativeSumRec(double array, int left, int
right).
Implement this function.
Program Output:
Array PArray= 2, 3, 4, 5, 6
Cumulative sum of PArray is : 20