កំណែលំហាត់ 6.5.1 - Managing Students ក្នុងមេរៀន ប្រភេទអញ្ញាតជា Static/Class Variables
#រៀនសរសេរកូដជាមួយចិត្រា #javaprogramming #javabasics #codingwithchitra #sololearncoding
JAVA ថ្នាក់ទី១ | JAVA For Beginner
លំហាត់
Exercise: Managing Students with Java Class Variables
Objective:
Practice using Java static/class variables to manage student information.
Instructions:
Student Class:
Create a Java class named Student with the following attributes:
studentId (int)
name (String)
grade (char)
Static Variables:
Add a static variable totalStudents to keep track of the total number of students.
Add a constant variable PASSING_GRADE with a value representing the passing grade (e.g., 'C').
Constructor:
Implement a parameterized constructor that initializes the instance variables.
Increment the totalStudents each time a new student is created.
Instance Method:
Implement an instance method displayStudentInfo that prints the details of a student (ID, name, grade).
Static Method:
Implement a static method displayTotalStudents that prints the total number of students.
Main Method:
In the main method, create at least four instances of the Student class with different details.
Display the details of each student using the displayStudentInfo method.
Call the displayTotalStudents method to show the total number of students.
Grade Checking:
Implement a method checkIfPass that checks if a student has passed (grade is equal to or above the passing grade).
Display a message indicating whether each student has passed or not.
កម្រងវីដេអូមេរៀន|Play List 👉 https://youtube.com/playlist?list=PLSJTJj3gU6qhkjSEUmgBKGJnn0ob1NZSu&si=rcvL8CwF_5EGx_2n
YouTube Channel 👉 https://www.youtube.com/@codingwithchitra
Facebook Page 👉 https://www.facebook.com/khmshared
Telegram Channel 👉 https://t.me/codingwithchitra