Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

LO4 Identify a system for controlling absenteeism.

Answered: 1 week ago

Question

LO2 Explain the nature of the psychological contract.

Answered: 1 week ago