Question: 8. (10 pt) Write a static method named countCoins that accepts a Scanner representing an input file whose data is many series of coins (penny,
8. (10 pt) Write a static method named countCoins that accepts a Scanner representing an input file whose data is many series of coins (penny, nickel, dime, or quarter) as a token. Each token will be "penny" (1 cent ench), "nickel" (5 cents each), "dime" (10 cents each) or quarter" (25 cents each), case-insensitively. The method should (1) count the number of coins, (ii) add up the cash values of all the coins, and (iii) print the total money by each row. For example, if the input file contains the following text: penny diMe Quarter quarter DiMe IMe nickel Penny Nickel quarter Dime penny quarter DiMe Nickel Quarter peNNy dime penny Quarter pEnny Nickel quarter quart ER dime DiMe dime Quarter penny nickel dine quarter DiMe For the input above, your method should produce the following output: 10 coins make $1.17 9 coins make $0.88 10 coins make $1.46. O coins make $0.00 5 coins make $0.41. The format of your output must exactly match that shown above. Assume the Scanner contains at least 1 line of input, and that no line will contain tokens other than penny, nickel, dime and quarter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
