Purchase Solution

C++ - british pounds,shillings,pence

Not what you're looking for?

Ask Custom Question

British pounds-shillings-pence money notation:

Design a class: pounds (type long), shillings (type int), pence(type int) data items.
create following member functions:
- no-argument constructor
- one-argument constructor, taking type double(for converting from decimal pounds)
- three-argument constructor, taking pounds, shillings and pence
- getSterling() to get an amount in pounds, shillings and pence from the user,
format $9.19.11
- putSterling() to display an amount in pounds, shillings and pence, format $9.19.11
- addition (sterling + sterling) using overloaded + operator
- subtraction (sterling - sterling) usind overloaded - operator
- multiplication (sterling * double) using overloaded * operator
- division (sterling / sterling) using overloaded / operator
- division (sterling / double) using overloaded / operator
- operator double (to convert to double)

- a penny can be further divided into halfpennies and farthings -> farthing worth 1/4 of a penny. There was a halfpenny coin, farthing coin, halffarthing coin.
it can be expressed in eights of a penny:
1/8 penny is a halffarthing
1/4 penny is a farthing
3/8 penni is a farthing and a half
1/2 penny is a halfpenny
5/8 penny is a halfpenny plus a halffarthing
3/4 penny is a halfpenny plus a farthing
7/8 penny is a halfpenny plus a farthing and a half

Assume we want to add to the sterling class the ability to handle such fractional pennies. The I/O format can be something like $1.1.1-1/4 or $9.19.11-7/8, where the hyphen separates the fraction from the pennies.

Derive a new class called 'sterfrac' from 'sterling'. It should be able to perform the four arithmetic operations on sterling quantities that include eights of a penny. Its only member data is an int indicating the number of eights; you can call it 'eights'.You'll need to overload many of the functions in 'sterling' to handle the eights. The user should
be able to type any fraction in lowest terms, and the display should also show fractions in lowest terms.

Purchase this Solution

Solution Summary

The expert designs a class for pounds, shillings and pence data items for member functions.

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Networking Questions

This quiz consists of some basic networking questions.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.