tailieunhanh - Java™ How to Program ( Deitel - Deitel) - Phần 13

Tham khảo tài liệu 'java™ how to program ( deitel - deitel) - phần 13', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 courseName name initialize courseName grades gradesArray store grades end two-argument GradeBook constructor method to set the course name public void setCourseName String name courseName name store the course name end method setCourseName method to retrieve the course name public String getCourseName return courseName end method getCourseName display a welcome message to the GradeBook user public void displayMessage getCourseName gets the name of the course Welcome to the grade book for n s n n getCourseName end method displayMessage perform various operations on the data public void processGrades output grades array outputGrades call methods getMinimum and getMaximum n s d n s d n n Lowest grade in the grade book is getMinimum Highest grade in the grade book is getMaximum output grade distribution chart of all grades on all tests outputBarChart end method processGrades find minimum grade public int getMinimum assume first element of grades array is smallest int lowGrade grades 0 0 loop through rows of grades array for int studentGrades grades loop through columns of current row for int grade studentGrades if grade less than lowGrade assign it to lowGrade 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 if grade lowGrade lowGrade grade end inner for end outer for return lowGrade return lowest grade end method getMinimum find maximum grade public int getMaximum assume first element of grades array is largest int highGrade grades 0 0 loop through rows of grades array for int studentGrades grades loop through columns of current row for int grade studentGrades if grade greater than highGrade assign it to highGrade if grade highGrade highGrade grade end inner

TỪ KHÓA LIÊN QUAN