Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/com/thealgorithms/Calculator.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/thealgorithms/Student.java
Original file line number Diff line number Diff line change
@@ -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; }
}
Loading