23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Write a <strong>Java</strong> program that can "make change." Your program should take two<br />

numbers as <strong>in</strong>put, one that is a monetary amount charged <strong>and</strong> the other that is a<br />

monetary amount given. It should then return the number of each k<strong>in</strong>d of bill<br />

<strong>and</strong> co<strong>in</strong> to give back as change for the difference between the amount given<br />

<strong>and</strong> the amount charged. The values assigned to the bills <strong>and</strong> co<strong>in</strong>s can be based<br />

on the monetary system of any current or former government. Try to design<br />

your program so that it returns the fewest number of bills <strong>and</strong> co<strong>in</strong>s as possible.<br />

Chapter Notes<br />

For a broad overview of developments <strong>in</strong> computer science <strong>and</strong> eng<strong>in</strong>eer<strong>in</strong>g, we refer<br />

the reader to The Computer Science <strong>and</strong> Eng<strong>in</strong>eer<strong>in</strong>g H<strong>and</strong>book [92]. For more<br />

<strong>in</strong>formation about the Therac-25 <strong>in</strong>cident, please see the paper by Leveson <strong>and</strong><br />

Turner [66].<br />

The reader <strong>in</strong>terested <strong>in</strong> study<strong>in</strong>g object-oriented programm<strong>in</strong>g further, is referred to<br />

the books by Booch [14], Budd [17], <strong>and</strong> Liskov <strong>and</strong> Guttag [69]. Liskov <strong>and</strong> Guttag<br />

[69] also provide a nice discussion of abstract data types, as does the survey paper by<br />

Cardelli <strong>and</strong> Wegner [20] <strong>and</strong> the book chapter by Demurjian [28] <strong>in</strong> the The<br />

Computer Science <strong>and</strong> Eng<strong>in</strong>eer<strong>in</strong>g H<strong>and</strong>book [92]. Design patterns are described <strong>in</strong><br />

the book by Gamma, et al. [38]. The class <strong>in</strong>heritance diagram notation we use is<br />

derived from the book by Gamma, et al.<br />

136

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!