subject

You are to write some overloaded operator methods for coinage objects that keep track of the amount of coins you have. A Coinage class will be used with the following six private data members: integer p for the number of pennies (eg 6)
integer n for the number of nickels (eg 4)
integer d for the number of dimes (eg 3)
integer q for the number of quarters (eg 5)
integer num for the total number of coins (eg 18 (6 + 4 + 3 + 5))
float amt for the total money amount for the coinage (eg 1.81 (6 * .01 + 4 *.05 + 3 * .10 + 5 * .25))
1. Overload the <= operator in the public section. Example: if (c1 <= c2) Your code should return true if the total money amount for c1 is less than or equal to the total money amount for c2.
2. Overload the + operator. Example: total = c1 + c2; Your code should add together the two Coinage objects c1 and c2 and place the total of these two objects into the total object. You will need to add together the corresponding data members and place these sums into total. For example, if c1 has 6 pennies and c2 has 10 pennies, then total has 6 + 10 =16 pennies.
3. Overload the ++ operator (preincrement). Example: ++c1; Your code should add one of each coin type to the c1 object. That is, c1 should have one additional penny, nickel, dime and quarter after the preincrement. Do not forget to recalculate the necessary data members.
4. Overload the ++ operator (postincrement). Example: c1++; Your code should add one of each coin type to the c1 object. That is, c1 should have one additional penny, nickel, dime and quarter after the postincrement. Do not forget to recalculate the necessary data members.
5. Overload the stream extraction operator. Example: cin >> c1;
6. Overload the stream insertion operator. Example: cout << c1;

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:30
Identify at least three types of characteristics that you were asked about as you the computer identify a fruit.
Answers: 3
question
Computers and Technology, 22.06.2019 15:10
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 2
You know the right answer?
You are to write some overloaded operator methods for coinage objects that keep track of the amount...
Questions
question
Mathematics, 05.05.2020 15:42
question
Mathematics, 05.05.2020 15:42
question
Mathematics, 05.05.2020 15:42
question
Mathematics, 05.05.2020 15:42
question
Mathematics, 05.05.2020 15:42
Questions on the website: 13722361