Write a BankAccount class that stores money in paise privately and offers deposit, withdraw (refusing overdrafts) and a formatted balance; process a list of transactions.
D 1500.50 ok Rs 1500.50
W 200.25 ok Rs 1300.25
W 5000.00 refused Rs 1300.25
D -10.00 refused Rs 1300.25
W 300.00 ok Rs 1000.25
Storing paise as an integer avoids floating-point rounding, and users never see it: they work in rupees through deposit/withdraw, and the class enforces "no overdraft, no negative deposits".
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!
We use Google Analytics cookies to see how LearnFrenzy is used and make it better, and Google AdSense to keep it free.
No analytics or ad cookies are set until you accept. Privacy Policy
·
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!