📄 courserecal.java
字号:
//Calculate the result of each course.
//Here we think all the scores are int value.
public class CourseReCal
{
//calculate method.
//Course result is determined by usual result
//and exam result.
//exam:70%,usual:30%.
public static final int SEVEN_TO_THREE=0;
//exam:60%,usual:40%.
public static final int SIX_TO_FOUR=1;
//exam:50%,usual:50%.
public static final int FIVE_TO_FIVE=2;
//Get the usual result from the int array.
//@param scores Each element of this arry is a schoolwork score.
public static int getUsualRe(int[] scores)
{
if(scores==null)
{
return 0;
}
else
{
int num=scores.length;
int results=0;
for(int i=0;i<num;i++)
{
results+=scores[i];
}
return (int)(results/num);
}
}
//Get the course total result.
//@param scores the array stores schoolword-scores.
//@param examRe the exam score.
//@param calMe the calculate method.One of the three above.
public static int getCourseRe(int examRe,int[] scores,int calMe)
{
int usualRe=getUsualRe(scores);
return getCourseRe(examRe,usualRe,calMe);
}
public static int getCourseRe(int examRe,int usualRe,int calMe)
{
if(usualRe==0)
{
return examRe;
}
if(calMe==SEVEN_TO_THREE)
{
return (int)(examRe*0.7f+usualRe*0.3f);
}
if(calMe==SIX_TO_FOUR)
{
return (int)(examRe*0.6f+usualRe*0.4f);
}
if(calMe==FIVE_TO_FIVE)
{
return (int)(examRe*0.5f+usualRe*0.5f);
}
else
return -1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -