虽然我确信这个答案很简单,但我不确定是否有人问我这个任务。这是我写的完整代码(所以才一回!),以及被赋予了指令:在粘贴如何将整数放入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连接起来,而无需更多信息。 –