I am a beginner to java - my university course module requires me to do an assignment - that is choose a system and build one.
i have chosen "Student Grading System" - this wont require a database.
i need to just enter student marks and thereby determine that subject grade, and then once all subject grades are determined calculae the gpa and identify the class level.
for now im working on 1st year subjects only.
i have absolutely no idea as to how i shud connect the code with a swing interface. below is the code i have.
CalculateGpa.java
public class CalculateGpa {
int softDevMarks;
int sadMarks;
int bisMarks;
int linuxMarks;
int managementMarks;
int maths1Marks;
int econMarks;
int socioMarks;
int numberOfSubjects = 8;
//Business Information System Marks
public int getBisMarks() {
return bisMarks;
}
public void setBisMarks(int bisMarks) {
this.bisMarks = bisMarks;
}
//Management Marks
public int getManagementMarks() {
return managementMarks;
}
public void setManagementMarks(int managementMarks) {
this.managementMarks = managementMarks;
}
//System Analysis and Design Marks
public int getSadMarks() {
return sadMarks;
}
public void setSadMarks(int sadMarks) {
this.sadMarks = sadMarks;
}
//Software Development Marks
public int getSoftDevMarks() {
return softDevMarks;
}
public void setSoftDevMarks(int softDevMarks) {
this.softDevMarks = softDevMarks;
}
//Mathematics 1 Marks
public int getMaths1Marks() {
return maths1Marks;
}
public void setMaths1Marks(int maths1Marks) {
this.maths1Marks = maths1Marks;
}
//PC Application Laboratory Marks
public int getLinuxMarks() {
return linuxMarks;
}
public void setLinuxMarks(int linuxMarks) {
this.linuxMarks = linuxMarks;
}
//Economics Marks
public int getEconMarks() {
return econMarks;
}
public void setEconMarks(int econMarks) {
this.econMarks = econMarks;
}
//Sociology marks
public int getSocioMarks() {
return socioMarks;
}
public void setSocioMarks(int socioMarks) {
this.socioMarks = socioMarks;
}
public static void main(String args[]) {
new CalculateGpa().calcGpa();
}
public double calcGpa() {
SubjectCredits subjectCredits = new SubjectCredits();
int softDevCredits = subjectCredits.getSoftwareDevCredits();
double softDevGpa = softDevCredits * subjectCredits.getGrade(softDevMarks);
int sadCredits = subjectCredits.getSadCredits();
double sadGpa = sadCredits * subjectCredits.getGrade(sadMarks);
int managementCredits = subjectCredits.getManagementCredits();
double managementGpa = managementCredits * subjectCredits.getGrade(managementMarks);
int bisCredits = subjectCredits.getBisCredits();
double bisGpa = bisCredits * subjectCredits.getGrade(bisMarks);
int bisCredits = subjectCredits.getLinuxCredits();
double linuxGpa = linuxCredits * subjectCredits.getGrade(linuxMarks);
int econCredits = subjectCredits.getEconCredits();
double econGpa = econCredits * subjectCredits.getGrade(econMarks);
int socioCredits = subjectCredits.getSocioCredits();
double socioGpa = socioCredits * subjectCredits.getGrade(socioMarks);
int maths1Credits = subjectCredits.getMaths1Credits();
double mathsGpa = mathsCredits * subjectCredits.getGrade(mathsMarks);
double gpaAverage = softDevGpa + sadGpa + managementGpa + bisGpa;
double gpa = gpaAverage/numberOfSubjects;
System.out.println("ICT 1001 - Software Development grade is : " + subjectCredits.getGradeRate(softDevMarks));
System.out.println("ICT 1002 - SAD grade is : " + subjectCredits.getGradeRate(sadMarks));
System.out.println("ICT 1005 - Management grade is : " + subjectCredits.getGradeRate(managementMarks));
System.out.println("ICT 1003 - BIS grade is : " + subjectCredits.getGradeRate(bisMarks));
System.out.println("GPA For this Semester is: " + gpa);
return gpa;
}
}
-----------------------------------------------------------------------------------
subjectCredits.java
public class SubjectCredits {
private String softwareDevelopment = "Software development";
private String sad ="System analysis and design" ;
private String management = "Management";
private String bis = "Business information systems";
private String softwareDevelopmentGrade;
private String sadGrade;
private String managementGrade;
private String bisGrade;
public int getSoftwareDevCredits() {
return 3;
}
public int getSadCredits() {
return 3;
}
public int getManagementCredits() {
return 2;
}
public int getBisCredits() {
return 2;
}
public String getSoftwareDevName() {
return softwareDevelopment;
}
public String getSadName() {
return sad;
}
public String getManagementName() {
return management;
}
public String getBisName() {
return bis;
}
public double getGrade(int marks) {
double gradepoints = 0;
if (marks >= 90) {
gradepoints = 3.75; //A+
} else if (marks < 90 && marks >= 80) {
gradepoints = 3.5; //A
} else if (marks < 80 && marks >= 70) {
gradepoints = 3.25; // A-
} else if (marks < 70 && marks >= 60) {
gradepoints = 2.75; // B+
}else if (marks < 60 && marks >= 70) {
gradepoints = 2.5; //B
}
return gradepoints;
}
public String getGradeRate(int marks) {
String grade = null;
if (marks >= 90) {
grade = "A+";
} else if (marks < 90 && marks >= 80) {
grade = "A";
} else if (marks < 80 && marks >= 70) {
grade = "A-";
} else if (marks < 70 && marks >= 60) {
grade = "B+";
}else if (marks < 60 && marks >= 70) {
grade = "B";
} else {
grade = "E";
}
return grade;
}
}
what shall i do??
please help