雖然我確信這個答案很簡單,但我不確定是否有人問我這個任務。這是我寫的完整代碼(所以才一回!),以及被賦予了指令:在粘貼如何將整數放入Java範圍內?
package code;
/**
* This class contains a variety of methods that will be used throughout the Ratings and Reviews
* project.
*/
public class Utilities{
/**
* Computes the average of two ratings
*
* @param rating0 An integer rating in the range of 1-5 inclusive
* @param rating1 An integer rating in the range of 1-5 inclusive
* @return the average of rating0 and rating1 as a double
*/
public double averageRating(int rating0, int rating1){
return ((rating0 + rating1)/2); // Don't forget to replace this return statement with your own
}
對不起壞結構。我認爲我的回報適合正在進行的工作,前提是評級可能只是任何事情。不過,我知道它只能在1-5之間,那麼如何指定呢?
有什麼指示? – Berger
請注意,這在初學者課程中很早,因此我正在尋找最簡單的解決方案。 –
你沒有描述這個問題,可能導致這個帖子被報告爲低質量。我正努力將標題與averageRating連接起來,而無需更多信息。 –