diff --git a/Calculator.java b/Calculator.java new file mode 100644 index 00000000..41e63464 --- /dev/null +++ b/Calculator.java @@ -0,0 +1,16 @@ +public class Calculator { + // ADDITION + public double add(double a, double b) { return a + b; } + // SUBTRACTION + public double sub(double a, double b) { return a - b; } + // MULTIPLICATION + public double mul(double a, double b) { return a * b; } + // DIVISION + public double div(double a, double b) { + if (b == 0) { + System.out.println("Error: Division by zero!"); + return 0; + } + return a / b; + } +} \ No newline at end of file diff --git a/Grade.java b/Grade.java new file mode 100644 index 00000000..236bb9ec --- /dev/null +++ b/Grade.java @@ -0,0 +1,51 @@ +public class Grade { + public String getLetterGrade(int score) { + if (score < 0 || score > 100) { + return "Invalid score"; + } else if (score >= 80) { + return "A"; + } else if (score >= 70) { + return "B"; + } else if (score >= 50) { + return "C"; + } else if (score >= 30) { + return "D"; + } else { + return "F"; + } + } + + public double getGradePoint(int score) { + if (score < 0 || score > 100) { + return -1; + } else if (score >= 80) { + return 4.0; + } else if (score >= 70) { + return 3.0; + } else if (score >= 50) { + return 2.0; + } else if (score >= 30) { + return 1.0; + } else { + return 0.0; + } + } + + public boolean isPassing(int score) { return score >= 30; } + + public String getRemark(int score) { + if (score < 0 || score > 100) { + return "Invalid score"; + } else if (score >= 80) { + return "Excellent"; + } else if (score >= 70) { + return "Good"; + } else if (score >= 50) { + return "Average"; + } else if (score >= 30) { + return "Pass"; + } else { + return "Fail"; + } + } +} \ No newline at end of file diff --git a/Student.java b/Student.java new file mode 100644 index 00000000..07938aa6 --- /dev/null +++ b/Student.java @@ -0,0 +1,37 @@ +public class Student { + private String name; + private int roll; + private String dept; + private String batch; + + // DEFAULT CONSTRUCTOR + public Student() {} + + // PARAMETERIZED CONSTRUCTOR + public Student(String name, int roll, String dept, String batch) { + this.name = name; + this.roll = roll; + this.dept = dept; + this.batch = batch; + } + + // COPY CONSTRUCTOR + public Student(Student student) { + this.name = student.getName(); + this.roll = student.getRoll(); + this.dept = student.getDept(); + this.batch = student.getBatch(); + } + + // GETTERS + public String getName() { return name; } + public int getRoll() { return roll; } + public String getDept() { return dept; } + public String getBatch() { return batch; } + + // SETTERS + public void setName(String name) { this.name = name; } + public void setRoll(int roll) { this.roll = roll; } + public void setDept(String dept) { this.dept = dept; } + public void setBatch(String batch) { this.batch = batch; } +} \ No newline at end of file