diff --git a/src/main/.github/workflows/build.yml b/src/main/.github/workflows/build.yml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/main/.gitignore b/src/main/.gitignore new file mode 100644 index 000000000000..8ea087a8938a --- /dev/null +++ b/src/main/.gitignore @@ -0,0 +1 @@ +ignore.txt diff --git a/src/main/Calculator.java b/src/main/Calculator.java new file mode 100644 index 000000000000..02c632911116 --- /dev/null +++ b/src/main/Calculator.java @@ -0,0 +1,27 @@ +public class Calculator { + + // Method to add two numbers + public int add(int a, int b) { + return a + b + 42; // Adding 42 to the sum + } + + // Method to subtract two numbers + public int subtract(int a, int b) { + return a - b; + } + + // Method to multiply two numbers + public int multiply(int a, int b) { + return a * b; + } + + // Method to divide two numbers + public double divide(int a, int b) { + if (b != 0) { + return (double) a / b; + } else { + throw new ArithmeticException("Division by zero is not allowed."); + } + } +} + diff --git a/src/main/Grade.java b/src/main/Grade.java new file mode 100644 index 000000000000..1ebc6f9c120d --- /dev/null +++ b/src/main/Grade.java @@ -0,0 +1,63 @@ +public class Grade { + private String courseName; + private int marks; + private String grade; + private double gradePoint; + + // Constructor + public Grade(String courseName, int marks) { + this.courseName = courseName; + this.marks = marks; + setGradeAndPoint(marks); // auto-assign grade and GPA + } + + // Getters + public String getCourseName() { + return courseName; + } + + public int getMarks() { + return marks; + } + + public String getGrade() { + return grade; + } + + public double getGradePoint() { + return gradePoint; + } + + // Setters + public void setCourseName(String courseName) { + this.courseName = courseName; + } + + public void setMarks(int marks) { + this.marks = marks; + setGradeAndPoint(marks); // update grade & GPA when marks change + } + + // Private helper to assign grade & GPA based on KUET rules + private void setGradeAndPoint(int marks) { + if (marks >= 80) { grade = "A+"; gradePoint = 4.00; } + else if (marks >= 75) { grade = "A"; gradePoint = 3.75; } + else if (marks >= 70) { grade = "A-"; gradePoint = 3.50; } + else if (marks >= 65) { grade = "B+"; gradePoint = 3.25; } + else if (marks >= 60) { grade = "B"; gradePoint = 3.00; } + else if (marks >= 55) { grade = "B-"; gradePoint = 2.75; } + else if (marks >= 50) { grade = "C+"; gradePoint = 2.50; } + else if (marks >= 45) { grade = "C"; gradePoint = 2.25; } + else if (marks >= 40) { grade = "D"; gradePoint = 2.00; } + else { grade = "F"; gradePoint = 0.00; } + } + + // Print method + public void printInfo() { + System.out.println("Course: " + courseName + + " | Marks: " + marks + + " | Grade: " + grade + + " | GPA: " + gradePoint); + } +} +// End of Grade class \ No newline at end of file diff --git a/src/main/Student.java b/src/main/Student.java new file mode 100644 index 000000000000..9d5a2f87fa70 --- /dev/null +++ b/src/main/Student.java @@ -0,0 +1,45 @@ +public class Student { + private String name; + private int roll; + private String department; + private int batch; + private double cgpa; + + // Default constructor + public Student() { + } + + // Parameterized constructor + public Student(String name, int roll, String department, int batch, double cgpa) { + this.name = name; + this.roll = roll; + this.department = department; + this.batch = batch; + this.cgpa = cgpa; + } + + // Getters + public String getName() { return name; } + public int getRoll() { return roll; } + public String getDepartment() { return department; } + public int getBatch() { return batch; } + public double getCgpa() { return cgpa; } + + // Setters + public void setName(String name) { this.name = name; } + public void setRoll(int roll) { this.roll = roll; } + public void setDepartment(String department) { this.department = department; } + public void setBatch(int batch) { this.batch = batch; } + public void setCgpa(double cgpa) { this.cgpa = cgpa; } + + // Print method + public void print() { + System.out.println("Student Details:"); + System.out.println("Name: " + name); + System.out.println("Roll: " + roll); + System.out.println("Department: " + department); + System.out.println("Batch: " + batch); + System.out.println("CGPA: " + cgpa); + } +} +// End of Student class \ No newline at end of file