/** * Exercise 12.5 p 471 */ public class Exercise125 { // All methods are private in the text. But make them public to be // able to test them. /** * a. * precondition: 0<=c AND c<=4 */ public int monetaryValue(int c) { // Take c as the index of an array element int[] table = {1,5,10,25,100}; return table[c]; } /** * precondition: 2<=m AND m<=10 */ public int mysteryValue(int m) { // Take m-2 as the index of an array element int[] table = {100,100,200,100,200,100,200,500,500}; return table[m-2]; } }