Question: C++ program design class Sterling that represent British currency that include the following functionality: Private class variables shillings and pence of type int and pound
C++ program design class Sterling that represent British currency that include the following functionality: Private class variables shillings and pence of type int and pound of type long. Default constructor that initializes the class variables with 0. A 3-argument constructor that initializes the class variables. Constructor with 1 parameter of type double interpreted as an amount in pounds that initializes the class variables accordingly (1 pound = 20 shillings = 240 pence). Get- and Set-methods for each class variable. Conversion operator that converts the class instance into a value of type double that represent the amount represented by the instance into pounds. Overloaded binary operators "+" and "-". Overloaded "*" operator that modifies an amount represented by the current class multiplied by a constant passed as a parameter. Overloaded binary "/" operator that computes the ratio of amounts represented by 2 class instances as a floating-point number. toString() method that returns a C++ string representation of the amount represented by the class instance in the format "#p.s.py", where p, s, and py are the amounts of pounds, shilling, and pence, respectively. Add a main() method into your code that demonstrates usage of all methods of class Sterling.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
