// package chapter5; /** * Title: Chapter 5, "Arrays" * Description: Examples for Chapter 2 * Copyright: Copyright (c) 2000 * Company: Armstrong Atlantic State University * @author Y. Daniel Liang * @version 1.0 */ // AssignGrade.java: Assign grade public class AssignGrade { /**Main method*/ public static void main(String[] args) { int numOfStudents = 0; // The number of students int[] scores; // Array scores int best = 0; // The best score char grade; // The grade // Get number of students System.out.println("Please enter number of students"); numOfStudents = MyInput.readInt(); // Create array scores scores = new int[numOfStudents]; // Read scores and find the best score System.out.println("Please enter " + numOfStudents + " scores"); for (int i=0; i best) best = scores[i]; } // Assign and display grades for (int i=0; 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'; System.out.println("Student " + i + " score is " + scores[i] + " and grade is " + grade); } } }