私のハッシュマップには、顧客名であるキーが含まれており、値は評価された本のすべての評価です。特定の本のタイトルの平均評価を計算する必要があります。
ハッシュマップからすべての値 (評価) にアクセスするにはどうすればよいですか? これを行う方法はありますか?
これが私のコードの一部です:
/**
* calculate the average rating by all customers for a named book
* only count positive or negative ratings, not 0 (unrated)
* if the booktitle is not found or their are no ratings then
* return NO_AVERAGE
* @param booktitle String to be rated
* @return double the average of all ratings for this book
*/
public double averageRating(String booktitle)
{
numberOfRatingsPerCustomer/total
}