Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Apologies: This is in Java. 2. (35 points) Write a program called CountCoins that prompts the user for the input file name then reads the
Apologies: This is in Java.
2. (35 points) Write a program called CountCoins that prompts the user for the input file name then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be "pennies" (1 cent each), "nickels" (5 cents each), "dimes" (10 cents each), or "quarters" (25 cents each), case-insensitively. You can assume the file is formatted properly. Add up the cash values of all the coins and print the total amount of money. For example, if the input file contains the following text: 3 pennies 2 quarters 1 Pennies 23 Nickels 4 DIMES For the input above, your method should produce the following output: Total money: $2.09 Hint: calculate in cents and then convert the result to dollars to print. Use constants for the coin valuesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started