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

CPP Exercises1

The document describes modifications to a bank account management program. It instructs to: 1. Add pin numbers for accounts and a special pin for the bank manager. Only the manager can do transactions to open/close the bank, print accounts, compute interest, and exit. 2. Store account details in a file when closing the program and restore them when reopening, allowing the bank state to persist after closing. 3. Create a date class with overloaded input/output operators to read and write dates as YYYY-MM-DD, and arithmetic operators to add/subtract days from a date.

Uploaded by

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

CPP Exercises1

The document describes modifications to a bank account management program. It instructs to: 1. Add pin numbers for accounts and a special pin for the bank manager. Only the manager can do transactions to open/close the bank, print accounts, compute interest, and exit. 2. Store account details in a file when closing the program and restore them when reopening, allowing the bank state to persist after closing. 3. Create a date class with overloaded input/output operators to read and write dates as YYYY-MM-DD, and arithmetic operators to add/subtract days from a date.

Uploaded by

kamakshi2
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

1.

Write a program that, given a date, three ints (for example, 11 27 1997), will print the number
of that day within its year: i.e. Jan 1st is always 1, Dec 31st is either 365 or 366.

2. Write a program to manage 100 bank accounts. The details of an account should be stored in
a class. Use member functions for the transactions on the accounts. The accounts have numbers
ranging from 1001 to 1100 (decimal). There are several types of transactions, which the program
will read. If allowed, the program may modify the account balance. Otherwise a warning
message will be printed. The dialogue for the transactions, have the following forms:

In the following, the bold type represents questions the program types to the user. Each response
to the transaction type question is a single character. Any attempted illegal transaction causes an
error message. Amounts are in dollars and can have 0, 1 or 2 digits after the point: 2765 or 123.4
or 8864.57:

Interaction Explanation
Open an account, giving the initial deposit.
Transaction type?: O
Allowed if less than 100 accounts now open.
Initial deposit?: amount
Prints the new account number.
Transaction type?: B A Balance inquiry, prints the account number
Account number?: account_number and the balance, only allowed if the account is open.
Transaction type?: D
A Deposit, prints the account number
Account number?: account_number
and new balance, only allowed if account open.
Amount?: amount
Transaction type?: W A Withdrawal, only allowed if account open
Account number?: account_number and sufficient funds available, prints
Amount?: amount account number and new balance.
Transaction type?: C Close the account. Only allowed if account
Account number?: account_number is open.
Transaction type?: I Compute interest at given % rate.
Interest rate?: interest_rate and apply to all accounts
Transaction type?: P Print all the account numbers and amounts.
Transaction type?: E Close all accounts and exit program

3. Add pin numbers to the bank accounts and add a special pin number for the bank manager.
Add a transaction type S to open the bank. Only the manager should be allowed to do
transactions S, P, I, and E. For each transaction, the computer must ask for the pin number. In an
Open transaction, the user chooses the pin number for the account.

4. Modify your bank program to store the accounts in a file when the program closes
(transaction E) and to restore the accounts from the file when the bank is opened (transaction S).
5. Create a class date and overload the << and >> operators for input and output of dates (operator>>
and operator<<). Dates should be output in the form 2013-01-10. The input operator should accept dates
in the same format. Overload the operator + and to add or subtract an integer from the date. That is
2014-02-26 + 5 should output 2014-03-02 and 2014-02-01 3 should give 2014-01-30.

You might also like