You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
733 B
27 lines
733 B
public class Main {
|
|
public static void main(String[] args) {
|
|
Student s1 = new Student("2021001", "Alice", 85.5);
|
|
Student s2 = new Student("2021002", "Bob", 92.0);
|
|
double score1 = s1.study();
|
|
double score2 = s2.study();
|
|
System.out.println(s1.name + " scored: " + score1);
|
|
System.out.println(s2.name + " scored: " + score2);
|
|
}
|
|
|
|
}
|
|
|
|
class Student {
|
|
public String studentId;
|
|
public String name;
|
|
public double score;
|
|
|
|
public Student(String studentId, String name, double score) {
|
|
this.studentId = studentId;
|
|
this.name = name;
|
|
this.score = score;
|
|
}
|
|
|
|
public double study() {
|
|
return this.score;
|
|
}
|
|
}
|
|
|