Question: (Intro to java help?) File Processing Write a static method named countMoney that accepts as its parameter a Scanner for an input file whose data
(Intro to java help?)
File Processing
Write a static method named countMoney that accepts as its parameter a Scanner for an input file whose data represents a person's money grouped into groups of bills. Your method should add up the cash values of all bills and print the total money at the end. The input consists of a series of pairs of tokens, where each pair begins with an integer and is followed by the type of bill, which will be either "bucks" (1 dollar each), "fives" (5 dollars each), "tens" (10 dollars each), "twenties" (20 dollars each), or fifties (50 dollars each). A given bill might appear more than once on the same line.
For example, if the input file contains the following text:
3 bucks 2 twenties 1 bucks 3 fives 4 tens 6 fifties
The total of these is 399, therefore your method would produce the following output if passed this input data.
Total money: $399
Here is a second example. Suppose the input file contains the following text. Notice the spacing:
12 twenties 1 bucks 33
bucks
10 fives
Then your method would produce the following output:
Total money: $324
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
Get step-by-step solutions from verified subject matter experts
