import javax.swing.JOptionPane;
public class ch0401{
  public static void main(String[] args) {
    int numberOfStudents=0; 
    int[] scores;
    int best =0; 
    char grade; 
    String numberOfStudentsString=JOptionPane.showInputDialog(null,"Please enter number of students:","Example 4.1 Input",JOptionPane.QUESTION_MESSAGE);
    numberOfStudents=Integer.parseInt(numberOfStudentsString);
    scores=new int[numberOfStudents];

    for (int i=0;i<scores.length;i++)  {
      String scoreString=JOptionPane.showInputDialog(null,"Please enter a score:","Example 4.1  Input",JOptionPane.QUESTION_MESSAGE);
      scores[i]=Integer.parseInt(scoreString);
      if (scores[i]>best)
        best=scores[i];
    }
    String output="";
    for(int i=0;i<scores.length;i++) {
      if(scores[i]>=best-10)
	  grade='A';
      else if(scores[i]>=best-20)
          grade='B';
      else if (scores[i]>=best-30)
          grade='C';
      else if (scores[i]>=best-40)
          grade='D';
      else
          grade ='F';
      output+="Student"+i+"score is "+scores[i]+" and grade is "+grade+"\n";
    }
  JOptionPane.showMessageDialog(null,output,"Example 4.1 Output",JOptionPane.INFORMATION_MESSAGE);
  }
}
