Question: Hello, C++ only please and done in this format please. There is a Java version of this if you need reference here: https://github.com/ramakastriot/practiceit/blob/master/chapter6/countCoins.java 10THE countCoins

 Hello, C++ only please and done in this format please. Thereis a Java version of this if you need reference here: https://github.com/ramakastriot/practiceit/blob/master/chapter6/countCoins.java

Hello, C++ only please and done in this format please. There is a Java version of this if you need reference here: https://github.com/ramakastriot/practiceit/blob/master/chapter6/countCoins.java

10THE countCoins PROBLEM Write a function countcoins that accepts an input stream and an output stream as arguments. The input stream represents a person's money grouped into stacks of coins. Add up the cash values of all the coins and print the total money at the end. Input is arranged as pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be either "pennies" (1 cent each), "nickels" (5 cents each), "dimes" (10 cents each), or "quarters" (25 cents each), case-insensitively. A given coin might appear more than once on the same line For example, if the input file contains the following text: 3 pennies 2 quarters 1 pennies 3 nickels 4 dimes 3 pennies are worth 3 cents, and 2 quarters are worth 50 cents, and 1 penny is worth 1 cent, and 3 nickels are worth 15 cents, and 4 dimes are worth 40 cents. The total of these is 1 dollar and 9 cents, therefore your function would produce the following output if passed this input data. Notice that the function should show exactly two digits after the decimal point, so it says 09 for 9 cents Total money: $1.09 Here is a second example. Suppose the input file contains the following text. Notice the capitalization and spacing 1 Pennies 12 QUARTERS PeNnies 1 nicKELs Then your function would produce the following output: Total money: $3.84 You may assume that the file contains at least 1 pair of tokens. You may also assume that the input is valid; that the input has an even number of tokens, that every other token is an integer and that the others are valid coin types

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!