Exercises: - SIUE



Exercises:

1. Repeat Exercise 2 in Chapter 7, but use an instance of ArrayList instead of an array. Do not read the number of values, but continue to read values until the user enters a negative value.

|Solution: |

| |

|See the code in CountFamilies.java. |

2. Repeat Exercise 3 in Chapter 7, but use an instance of ArrayList instead of an array. Do not read the number of families, but read data for families until the user enters the word done.

|Solution: |

| |

|See the code in Family.java and CountPoor.java. |

3. Repeat Exercise 5 in Chapter 7, but use an instance of ArrayList instead of an array.

|Solution: |

| |

|See the code in CharacterFrequency.java. |

4. Repeat Exercises 6 and 7 in Chapter 7, but use an instance of ArrayList instead of an array. We will no longer need to know the maximum number of sales, so the methods will change to reflect this.

|Solution: |

| |

|See the code in Ledger.java. |

5. Write a static method removeDuplicates(ArrayList data)

that will remove any duplicates of characters in the object data. Always keep the first copy of a character and remove subsequent ones.

|Solution: |

| |

|public static void removeDuplicates(ArrayList data){ |

|for(int i=0; i ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download