Page 315 - Computer_Science_F5
P. 315
Computer Science 13. The NMB ATM allows a customer 15. Write a C++ program to implement
discuss their advantages and use
to withdraw a maximum of Tshs
cases.
1,000,000/= per day. If a customer
withdraws more than Tshs
a class called Shape with virtual
FOR ONLINE READING ONLY
335,000/= the service charge is 6%
of the amount over Tshs 335,000/=. member functions for calculating
area and perimeter. Derive classes
If the customer does not have such as Circle, Rectangle, and
sufficient money in the account, Triangle from the Shape class
the ATM informs the customer and override virtual functions
about the insufficient fund and accordingly.
gives the option to withdraw the 16. Write a C++ program to display the
money for a service charge of Tshs following patterns:
1250/=. If there is no balance in the
account or if the account balance
is negative, the customer will not
be allowed withdraw any money
from the ATM. If the amount
to be withdrawn exceeds Tshs Figure 4.75: (a) Figure 4.75: (b)
1,000,000/= , the ATM informs 17. Create a calendar using a C++
the customer about the maximum programming language. A program
amount that can be withdrawn. will prompt a user to enter a year
Write an algorithm that allows followed by a month in a number.
the customer to enter the amount Then, the calendar will be displayed
to be withdrawn. The algorithm as shown in Figure 4.76.
should check the total amount in the
account, dispense the money to the
customer, and debit the customer
account by the amount withdrawn
and the service charges, if any.
14. Explain the concept of polymorphism
and its different types, such as
compile-time polymorphism
(function overloading) and runtime Figure 4.76:
polymorphism (virtual functions), in Hints:
C++. Provide examples illustrating (a) Use Switch case statement to change
each type of polymorphism and the month entered by the user in a
306
for Advanced Secondary Schools
Computer Science Form 5.indd 306 23/07/2024 12:34

