/**
*
* @ Author: Kevin
* @ Date: 2011-07-18
* @ Function: to mark 0-10 point to players, and the result is delete the highest
* And the lowest, at last reserve the average marks.
*/
Package com. Homework;
Import java. util. collections;
Public class marksystem {
// Main method
Public static void main (string [] ARGs ){
Voter voter = new voter ();
System. Out. println ("the last mark is:" + voter. lastmark ());
System. Out. println ("the worst judger is no.:" + voter. getworst ());
}
}
//-------------------------------------------
// Create class player
Class voter
{
Private float [] Mark = NULL;
Private int size = 8;
// Constructor
Public voter ()
{
S = new partition (system. In );
System. Out. println ("Enter the number of participants (more than 3 ):");
Size = S. nextint ();
Mark = new float [size];
For (INT I = 0; I <size; I ++)
{
System. Out. println ("input the No." + (I + 1) + "judger 'Mark ");
Mark [I] = S. nextfloat ();
}
}
Public float lastmark ()
{
Float lastmark = 0;
Int minindex = This. getlowmarkindex ();
Int maxindex = This. gethigmarkindex ();
For (INT I = 0; I <size; I ++)
{
If (I! = Minindex & I! = Maxindex)
{
Lastmark + = mark [I];
}
}
Return lastmark/(size-2 );
}
// Obtain the lowest score number
Public int getlowmarkindex ()
{
Float lowmark = mark [0];
Int lowindex = 0;
For (INT I = 0; I <size; I ++)
{
If (lowmark> MARK [I])
{
Lowmark = mark [I];
Lowindex = I;
}
}
Return lowindex;
}
// Retrieve the highest score
Public int gethigmarkindex ()
{
Float higmark = mark [0];
Int higindex = 0;
For (INT I = 0; I <size; I ++)
{
If (higmark <mark [I])
{
Higmark = mark [I];
Higindex = I;
}
}
Return higindex;
}
// Retrieve the worst judge's number
Public int getworst ()
{Float lastmark = This. lastmark ();
Int worstindex = 0;
Float CHA = math. Abs (MARK [0]-lastmark );
Float cha2 = 0f;
For (INT I = 0; I <size; I ++)
{
Cha2 = math. Abs (MARK [I]-lastmark );
If (CHA <cha2)
{
Worstindex = I;
}
}
Return worstindex + 1;
}
}