The system is able to find grade for each course based on final marks, calculate GPA, Calculate CGPA.
Methods (menu);
i. Input matric_number, name, coursecode, credithours, semester, final marks for each subject. You may use text file ii. Calculate GPA and CGPA for each student. iii. Search a student record iv. Print Report for all students order by CGPA ascending
Any way to implement linked list?
import java.util.Scanner;
import java.util.Date;
import java.util.InputMismatchException;
public class Student {
private String name,Grade,matricNumber,courseCode;
private int creditHours,semester;
private Date dateCreated=new Date();
private double finalMarks;
Student(String name,int creditHours,int semester,String matricNumber,String courseCode,double finalMarks){
this.name=name;
this.creditHours=creditHours;
this.matricNumber=matricNumber;
this.finalMarks=finalMarks;
this.courseCode=courseCode;
this.semester=semester;
}
void setfinalMarks(double finalMarks){
this.finalMarks=finalMarks;
}
double getfinalMarks(){
return finalMarks;
}
void setmatricNumber(String matricNumber){
this.matricNumber=matricNumber;
}
String getmatricNumber(){
return matricNumber;
}
void setcourseCode(String courseCode){
this.courseCode=courseCode;
}
String getcourseCode(){
return courseCode;
}
void setcreditHours(int creditHours){
this.creditHours=creditHours;
}
int getcreditHours(){
return creditHours;
}
void setsemester(int semester){
this.semester=semester;
}
int getsemester(){
return semester;
}
double getPoint(){
return creditHours*finalMarks;
}
void setName(String name){
this.name=name;
}
String getName(){
return name;
}
void setGrade(String Grade){
this.Grade=Grade;
}
String getGrade(){
return Grade;
}
Date dateCreated(){
return dateCreated;
}}
class StudentGrade{
public static void main(String[] args) {
String name,matricNumber=null,courseCode=null,Grade=null;
boolean valid;
double point=0;
int creditHours = 0;
int semester=0;
boolean continueInput = false;
double finalMarks=0;
Scanner input=new Scanner(System.in);
int i=0;
System.out.println("Please enter student's name:");
name=input.next();
int y=0;
valid=true;
input.nextLine();
System.out.println("Please enter matric number:");
matricNumber = input.nextLine();
do{
continueInput = false;
try{
System.out.println("Please enter semester:");
semester = input.nextInt();}
catch(InputMismatchException ex){
System.out.println("Invalid input.Please try again.");
continueInput=true;
input.nextLine();
}
}
while (continueInput);
input.nextLine();
System.out.println("Please enter course code:");
courseCode = input.nextLine();
do{
System.out.println("Please enter creditHour(1,2,3):");
creditHours = input.nextInt();
while(creditHours<1||creditHours>3){
System.out.println("Please enter credit Hour again(1,2,3):");
creditHours = input.nextInt();
}
System.out.println("Please enter finalMarks:");
finalMarks = input.nextDouble();
if(finalMarks>=80&&finalMarks<=100){
Grade="A";
}
else if(finalMarks>=70&&finalMarks<=79){
Grade="A-";
}
else if(finalMarks>=70&&finalMarks<=74){
Grade="B+";
}
else if(finalMarks>=65&&finalMarks<=69){
Grade="B";
}
else if(finalMarks>=60&&finalMarks<=64){
Grade="B-";
}
else if(finalMarks>=55&&finalMarks<=59){
Grade="C+";
}
else if(finalMarks>=50&&finalMarks<=54){
Grade="C";
}
else if(finalMarks>=45&&finalMarks<=49){
Grade="C-";
}
else if(finalMarks>=40&&finalMarks<=44){
Grade="D";
}
else if(finalMarks>=30&&finalMarks<=39){
Grade="E";
}
else {
Grade="F";
}
switch(Grade){
case "A":
point=4.00*creditHours;
break;
case "A-":
point=3.67*creditHours;
break;
case "B+":
point=3.33*creditHours;
break;
case "B":
point=3.00*creditHours;
break;
case "B-":
point=2.67*creditHours;
break;
case "C+":
point=2.33*creditHours;
break;
case "C":
point=2.00*creditHours;
break;
case "C-":
point=1.67*creditHours;
break;
case "D":
point=1.33*creditHours;
break;
case "E":
point=1.00*creditHours;
break;
case "F":
point=0.00*creditHours;
break;
}
int x=0;
Student people1=new Student(name,creditHours,semester,matricNumber,courseCode,finalMarks);
System.out.println("Student's name: "+people1.getName()+"\nMatric number: "+people1.getmatricNumber()+"\nSemester: "+people1.getsemester()+"\nCourse Code: "+people1.getcourseCode()+"\nCredit Hours:"+people1.getcreditHours()+"\nFinal Marks: "+people1.getfinalMarks()+"\nPoint:"+point+"\nGrade:"+Grade+"");
System.out.println("The date created"+people1.dateCreated());
do{
if(continueInput == false){
System.out.println("Chose 1 to continues,chose 2 to exit the system");
x = input.nextInt();
input.nextLine();
if(x==1){
System.out.println("System will be continues.");
x++;
}
else if(x==2){
System.out.println("System exit.");
System.exit(x);//System exit
}
else{
System.out.println("Invalid input,please retry.");
input.nextLine();
}
}
}while(x==1);
}while(continueInput);
}
}
Bold Text Here