Saturday, February 23, 2013

array4

import java.util.Scanner;

 public class array4 {
  
   public static void main(String[] args) {
       Scanner input=new Scanner(System.in);
  
      
     String numberstudents;
     System.out.print("Enter number of students:");
     numberstudents=input.next();

  
     int num = Integer.parseInt(numberstudents);

    int[] scores = new int[num];
    int best = 0;
  
    
    for (int i = 0; i < scores.length; i++) {
      String score;
      System.out.print("Enter a score:");
      score=input.next();
      
  
     scores[i] = Integer.parseInt(score);
       if (scores[i] > best)
        best = scores[i];
     }
 
     String output = "";
  
     for (int i = 0; i < scores.length; i++) {
      if (scores[i] >= best - 10)
     

      output += "Student "  + "biggest score is " +
         scores[i] ;
     }
    
     System.out.println( output);
         
   }
}

No comments:

Post a Comment