Uploaded by waaj29

assingme2

advertisement
Pir Mehr Ali Shah
Arid Agriculture University, Rawalpindi
University Institute of Information Technology
Course Code: CS-423
Course Title: Object Oriented Programming
Degree: BS-CS-2A/2B-Mor
Total Marks:
____10___________________
Due Date: 11-April-2022
Obtained Marks: ______________________
Teacher Signature: ____________________
Student Name: ________________________
Reg. No. : ___________________________
Assignment No. 2
Note: Assignment should be hand-written and on proper sheets. Attach screenshot of the
program output. Copy paste assignments will be cancelled and marked as zero.
Q. No.1:
You are required to write a class book management system in which one can enter the record of
new books and retrieve the details of books available in the library. Then derive a class which keep
issue books to the students and maintain their records. Late fine is charged for students who
returns the issued books after the due dat. Only one book is issued to students. New book is not
issued to students those not returned the last book.
Q. No.2:
Write a C++ program at your own choice which shows function overriding (At least three function)
and test it through main function by creating multiple objects. Create a program that asks the
user to enter the names of their last three employers. Output the names entered to confirm. Ask
the user if the confirmation output is correct. If Yes, end the program. If No, then ask for the
three names again.
Output:
This program will ask you to enter the company name of your last three employers.
Enter the company name: [user types: 123 Corp]
Enter the company name: [user types: 789 Corp]
Enter the company name: [user types: Kendall Corp]
These are the company names you entered:
123 Corp
789 Corp
Kendall Corp
Are these three names correct (Y or N)? [user types: n]
Enter the company name: [user types: ABC Corp]
Enter the company name: [user types: XYZ Corp]
Enter the company name: [user types: Miami Corp]
These are the company names you entered:
ABC Corp
XYZ Corp
Miami Corp Are these three names correct (Y or N)?
[user types: y]
Question#3
Define class BankAccount to store a bank customer’s account number and balance. Suppose that
account is of type int and balance is type double. Your class should at least provide the following
operations set the account deposit and withdraw money and print account information, Add
offer a check
Q.NO.3
Pakistan Cricket Board (PCB) is looking for a solution to record the information about their
different types of players. Under the contract of PCB there are three (3) different type of players.
Suppose you are asked to develop a system, which input all the data of player and calculate & print
the total scores and income of a cricket player of Pakistan cricket team. Each player is identified
by name, CNIC, income and score. There are three types of players - Test, OneDay, T20. A player
can be in all types but If player is not playing in any one or more types then you will input zero(0)
for the data members of that class. Each type of Player gets paid using a different formula. OneDay
Players are paid by their Monthly fixed salary of Rs.100,000/- per month, test players are paid by
the number of hours they played at rate of Rs.2000/- per hour, while T20 players are being played
by the number of matches they have played at the rate of 50000/- per match. Keeping in mind the
above scenario,
1.
2.
3.
4.
Write the complete states and behaviors of child and parent classes
Write the constructor for each class.
Apply method overriding in child classes.
Exercise the main function to test these classes. Here is one of the Example Output if player
is not playing T20:
Enter Player Name: Shahid Afridi
Enter CNIC:12345-6783765-1
Enter Test Hrs:20
Enter Score in Test:10000
Enter salary_per_month:3
Enter Score in One Day:5000
Enter no_of_matches in T20:0
Enter Score in T20:0
Player Records Added by Your Registration Number ---------------------------------------------Player Name: Shahid Afridi
Player CNIC: 12345-6783765-1
Total Score is:15000 Total Income is: 340000
Q.No.4:
Define the class bankAccount to store a bank customer's account number and balance. Suppose
that account number is of type int, and balance is of type double. Your class should, at least,
provide the following operations: set the account number, retrieve the account number, retrieve
the balance, deposit and withdraw money, and print account information. Add appropriate
constructors.

Every bank offers a checking account. Derive the class checking Account from the class
bankAccount. This class inherits members to store the account number and the balance
from the base class. A customer with a checking account typically receives interest,
maintains a minimum balance, and pays service charges if the balance falls below the
minimum balance. Add member variables to store this additional information. In addition
to the operations inherited from the base class, this class should provide the following


operations: set interest rate, retrieve interest rate, set minimum balance, retrieve minimum
balance, set service charges, retrieve service charges, post interest, verify if the balance is
less than the minimum balance, write a check, withdraw (override the method of the base
class), and print account information. Add appropriate constructors.
Every bank offers a savings account. Derive the class savings Account from the class
bankAccount (designed in part (a)). This class inherits members to store the account
number and the balance from the base class. A customer with a savings account typically
receives interest, makes deposits, and withdraws money. In addition to the operations
inherited from the base class, this class should provide the following operations: set interest
rate, retrieve interest rate, post interest, withdraw (override the method of the base class),
and print account information. Add appropriate constructors.
Write a program to test your classes designed in parts (b) and (c).
Don’t copy paste, write your own program. Marks will be awarded for uniqueness not for
correctness.
Download