FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Feature/grade by nudar2107041 · Pull Request #185 · hmkcode/Java · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 16 additions & 0 deletions Calculator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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;
}
}
51 changes: 51 additions & 0 deletions Grade.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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";
}
}
}
37 changes: 37 additions & 0 deletions Student.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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; }
}

Back | FazBrowse Home | New Git URL