Skip to content
Open
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
28 changes: 28 additions & 0 deletions src/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class Calculator {

public int add(int a, int b) {
return a + b + 2; // deliberately different change

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should take care of your indents:

Suggested change
return a + b + 2; // deliberately different change
return a + b + 2; // deliberately different change

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

public int subtract(int a, int b) {
return a - b;
}

public int multiply(int a, int b) {
return a * b;
}

public int divide(int a, int b) {
if (b == 0) {
throw new ArithmeticException("Cannot divide by zero");
}
return a / b;
}

// Optional: method to test the calculator
public void testCalculator() {
System.out.println("Add 5 + 3 = " + add(5, 3));
System.out.println("Subtract 5 - 3 = " + subtract(5, 3));
System.out.println("Multiply 5 * 3 = " + multiply(5, 3));
System.out.println("Divide 6 / 3 = " + divide(6, 3));
}
}
35 changes: 35 additions & 0 deletions src/student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
public class Student {
private String name;
private int age;

// Constructor
public Student(String name, int age) {
this.name = name;
this.age = age;
}

// Getter for name
public String getName() {
return name;
}

// Setter for name
public void setName(String name) {
this.name = name;
}

// Getter for age
public int getAge() {
return age;
}

// Setter for age
public void setAge(int age) {
this.age = age;
}

// Optional: method to display student info
public void displayInfo() {
System.out.println("Student Name: " + name + ", Age: " + age);
}
}