0% found this document useful (0 votes)
7 views2 pages

PS6 Array of Objects

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)
7 views2 pages

PS6 Array of Objects

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

PSG College of Technology, Coimbatore- 04

Department of Applied Mathematics and Computational Sciences


23XT27 - Object Oriented Programming Lab
Problem Sheet – V

1. ABC Bank updates its customers’ accounts at the end of each month. The bank offers two
types of accounts: savings and checking. Every customer must maintain a minimum
balance 1000 for savings account and 5000 for checking account. If a customer’s balance
falls below the minimum balance, there is a service charge of Rs. 500 for savings account
and RS.1500 for checking account. Also, If the balance at the end of the month is at least
the minimum balance, then the account receives interest as follows:
a. Savings account receives 4% interest
b. Checking account with balance of up to RS. 250000 receive 3% interest; an account
with balance greater than 250000 receives 5% interest.
Write a program that reads a customer’s account number (int type), account type(char; s
for savings, c for checking), and current balance. The program should then output the
account number, account type, current balance, and an appropriate message.
2. Define a class named GroceryItem. Include private fields that hold an item’s stock
number, price, quantity in stock, and total value. Write a public function named
dataEntry() that calls four private functions. Three of the private functions prompt the
user for keyboard input for a value for one of the data fields stock number, price, and
quantity in stock. The function that sets the stock number requires the user to enter a
value between 1000 and 9999 inclusive; continue to prompt the user until a valid stock
number is entered. The functions that set the price and quantity in stock require non-
negative values; continue to prompt the user until valid values are entered. Include a
fourth private function that calculates the GroceryItem’s total value field (price times
quantity in stock). Write a public function that displays a GroceryItem’s values. Finally,
write a main() function that declares a GroceryItem object, assigns values to its fields,
and uses the display function.
3. Write a program to store student details. Create a class Student with data members
RollNo, Name, Course, Branch, and Semester. Store them in an array of objects. Input
the total number of students. The menu must comprise of the following:
a) Sorted list of students in the ascending order of Name
b) Course wise student list
c) Semester wise student list
d) Branch wise student list
4. Define a class called Cricket that will describe the members Player name, Team name,
and Batting average.
Write a program to read details of ‘n’ players (array of objects) using read(). Define two
member functions with same name Display() using function overloading concept, the first
member function Display(), takes no argument, which prints the details of a player of the
corresponding object, and the second Display() takes array of objects as argument, which
prints the details of all players.
5. The health visitor of a school is going to measure the heights of all pupils. For each class
she makes a statistics giving the number pupils of each height and the average height.
Develop a C++ program to print the statistics in the following format for 5 classes by
creating an array of objects.
Class A :
Heigh Number of
t Pupils
164 2
160 1
155 4
… …
… …
182 2
Average Height : 172.0

You might also like