Student Report Card
easyStore a student's marks in three subjects and print the total, average and grade.
Class and objectFieldsMethodsConditions
Steps
- 1Create a class Student with fields name, m1, m2, m3.
- 2Add a constructor that sets all four values.
- 3Add a method total() that returns the sum of the three marks.
- 4Add a method average() that returns total() / 3.0.
- 5Add a method grade() that returns A, B, C or Fail using if-else on the average.
- 6In main, create one Student and print a neat report card.
Starter code
class Student {
String name;
int m1, m2, m3;
Student(String name, int m1, int m2, int m3) {
// TODO: use this.
}
int total() { return 0; }
double average() { return 0; }
String grade() { return ""; }
}
public class Main {
public static void main(String[] args) {
Student s = new Student("Asha", 78, 85, 91);
// TODO: print name, total, average, grade
}
}