1. Student { double getTuition() { HR humRes; Person father = getFather(); int fatherID = humRes.getEmployeeID(father); Employee fatherEmp = humRes.getEmployee(fatherID); // possibly invalid! Person mother = getMother(); int motherID = humRes.getEmployeeID(mother); Employee motherEmp = humRes.getEmployee(motherID); // possibly invalid! if (fatherID != -1 && fatherEmp.getClassification() == 0) return 5000; else if (motherID != -1 && motherEmp.getClassification() == 0) return 5000; else if (fatherID != -1 && fatherEmp.getClassification() == 1) return 7500; else if (motherID != -1 && motherEmp.getClassification() == 1) return 7500; else return 10000; } ---------------------------------------------------------------------- a more cautious alternative coding ..... Employee fatherEmp; Employee motherEmp; if (fatherID != -1) { fatherEmp = humRes.getEmployee(fatherID); } if (motherID != -1) { motherEmp = humRes.getEmployee(motherID); } ---------------------------------------------------------------------- an example of INCORRECT code (overcharges a student whose father is staff and whose mother is faculty if (fatherID != -1 && fatherEmp.getClassification() == 0) return 5000; else if (fatherID != -1 && fatherEmp.getClassification() == 1) return 7500; else if (motherID != -1 && motherEmp.getClassification() == 0) return 5000; else if (motherID != -1 && motherEmp.getClassification() == 1) return 7500; else return 10000; ---------------------------------------------------------------------- 2. Library lib("Engineering"); for (int b = 0; b < lib.getBookCount(); b++) { Book bk = lib.getBook(i); if (bk.getPublicationDate() < 1970) { // book is old if (bk.getCheckOutCount() > 1) { // keep this old book } else { bk.markForDiscard(); } } } ---------------------------------------------------------- an alternative Library lib("Engineering"); for (int b = 0; b < lib.getBookCount(); b++) { Book bk = lib.getBook(i); if (bk.getPublicationDate() < 1970 && bk.getCheckOutCount() <= 1) { bk.markForDiscard(); } } ------------------------------------------------------------------------- 3. Two solutions depending on how you interpreted or fixed the problem char cityName[MAXSTR]; Forecasts casts[10]; leastRain = -1; City leastRainyCity; // for all cities for (int c = 0; c < cityCount; c++) { cities[c].getName(cityName); WeatherService ws(cityName); // construct a WeatherService object with city name ws.getForecasts(10,casts); double totRain = 0; for (int d = 0; d < 10; d++) { totRain += casts[d].getRainfall(); } if (leastRain == -1 || totRain < leastRain) { leastRain = totRain; leastRainyCity = cities[c]; } } leastRainyCity.getName(cityName); cout << cityName; ----------------------------------------------------------- WeatherService ws("Weather Channel"); char cityName[MAXSTR]; Forecasts casts[10]; leastRain = -1; City leastRainyCity; // for all cities for (int c = 0; c < cityCount; c++) { ws.getForecasts(10,casts,cities[c]); // specify city in getForecasts double totRain = 0; for (int d = 0; d < 10; d++) { totRain += casts[d].getRainfall(); } if (leastRain == -1 || totRain < leastRain) { leastRain = totRain; leastRainyCity = cities[c]; } } leastRainyCity.getName(cityName); cout << cityName; 4. Person homer("Homer"); double allowance = homer.getCalorieAllow(); for (int d = 0; d < dessertCount; d++) { if (desserts[d].getCalories() <= 0.1*allowance && homer.likes(desserts[d]) { desserts[d].display(); } } 5. int getDayOfYear() { int dayOfYear = 0; // preceding months for (int m = 1; m < month-1; m++) { dayOfYear += daysInMonth(m); } if (isLeapYear(year) && m > 2) dayOfYear++; dayOfYear += day; return dayOfYear; }