In: Computer Science
The Garden school want to build a system to calculate students' grade and check they can apply for a scholarship. The system can let the administrator can log in this system (no database required) to work with different students' marks. You need to use the weight of each unit to calculate the final grade. The administrator should enter their account and password at first. They can start work when the account and password are correct. The administrator needs to typing students ID, and according to your prompts to type the following units' marks. The system must according to those marks to provide the final grade of the students. According to the description, the system should analysis each unit's marks to provide suitable prompts to let the administrator know that the student meets requirements. According to those results, the administrator can inform those students. Unit Name Description Weight Math Students can attend maths contest when they get 90 marks 30% Biology Students can apply the unit Ecology when they get 75 20% IT Students can get a Microsoft certificate when they get 85 in this unit 20% Painting Students' productions can be displayed on the school website when they can get 85 in this unit. 10% History 20% Final The student has the opportunity to apply for a scholarship when the final grade is HD. 100% Grade table Marks Grade Note >= 85 HD >=75 D >=65 C >=50 P <50 F Students need to enrol this unit next semester. Units' marks are 0 Not attend Students need to explain their absence and enrol this unit next semester. In the system, staff can type student’s id to find the students mark details, and staff can get a .txt file of the student's mark details. In the system, the student can use an account and password to login the system to check their marks and enrol their units. Students can type in the unit code to enrol their unit. One student can enrol no more than 4 unit at a semester. If a student enrols the unit first time, the fee of the unit will be plan A. If the student is the second time to enrol this unit (due to failed last semester), the fee of the unit would be plan B. For example, a student got F in math last semester; the student needs to enrol the unit this semester, but the fee is 1200 instead of 1000. The following are the units that students can enrol Unit Code Unit Name Fee (plan A) $AUD Fee (plan B) $AUD 4483 Math 1000 1200 4485 Biology 1580 1780 4486 Information technology 1580 1780 4487 Painting 1580 1780 4488 History 1000 1200 4489 Ecology 1000 1200 8873 Accounting 1000 1200 8872 Chief 1580 1780 8871 Spanish 1200 1200 Student can get a .txt file when they finish their enroll. There is a student record which is already saved in your program, the student can login the system to check his unit marks and final grade. The student will get Plan B fee when he enrols failed units. You need to display the fee of each unit, and the total fee of all unit. Staff also can get the student information when type in the student ID: Name: Tom ID: u123 Password: u123 Math: 48 Biology: 52 IT: 53 Painting: 45 History: 38 Final grade: F The student needs to enrol math, painting, history next semester.
package com.demo.qa.Dto;
public class Student {
private String studentId;
private String studentFirstName;
private String studentLastName;
private String studentPassword;
public String getStudentPassword() {
return studentPassword;
}
public void setStudentPassword(String studentPassword) {
this.studentPassword = studentPassword;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getStudentFirstName() {
return studentFirstName;
}
public void setStudentFirstName(String studentFirstName) {
this.studentFirstName = studentFirstName;
}
public String getStudentLastName() {
return studentLastName;
}
public void setStudentLastName(String studentLastName) {
this.studentLastName = studentLastName;
}
@Override
public String toString() {
return "Student [studentId=" + studentId + ", studentFirstName=" + studentFirstName + ", studentLastName="
+ studentLastName + ", studentPassword=" + studentPassword + "]";
}
}
package com.demo.qa.Dto;
public class GradeData {
private int marks;
private String grade;
private String note;
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
@Override
public String toString() {
return "GradeData [marks=" + marks + ", grade=" + grade + ", note=" + note + "]";
}
}
package com.demo.qa.Dto;
public class Unit {
private String unitName;
private String description;
private int weight;
private int marks;
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
@Override
public String toString() {
return "Unit [unitName=" + unitName + ", description=" + description + ", weight=" + weight + ", marks=" + marks
+ "]";
}
}
package com.demo.qa.Dto;
public class FeePlan {
private int unitCode;
private String unitName;
private int feePlanA;
private int feePlanB;
public int getUnitCode() {
return unitCode;
}
public void setUnitCode(int unitCode) {
this.unitCode = unitCode;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public int getFeePlanA() {
return feePlanA;
}
public void setFeePlanA(int feePlanA) {
this.feePlanA = feePlanA;
}
public int getFeePlanB() {
return feePlanB;
}
public void setFeePlanB(int feePlanB) {
this.feePlanB = feePlanB;
}
@Override
public String toString() {
return "FeePlan [unitCode=" + unitCode + ", unitName=" + unitName + ", feePlanA=" + feePlanA + ", feePlanB="
+ feePlanB + "]";
}
}
package com.demo.qa.Dto;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class MainClass {
private List<Unit> uList;
private List<GradeData> gradeList;
private List<FeePlan> feeList;
private List<Student> studentList;
private static Scanner myObj;
public void setUnitListData() {
List<Unit> uList = new ArrayList<Unit>();
Unit unit = new Unit();
unit.setMarks(90);
unit.setUnitName("Maths");
unit.setDescription("Students can attend maths contest when they get 90 marks");
unit.setWeight(30);
uList.add(unit);
Unit unit1 = new Unit();
unit1.setMarks(75);
unit1.setUnitName("Biology");
unit1.setDescription("Students can apply the unit Ecology when they get 75");
unit1.setWeight(20);
uList.add(unit1);
Unit unit2 = new Unit();
Unit unit3 = new Unit();
unit2.setMarks(85);
unit2.setUnitName("IT");
unit2.setDescription("Students can get a Microsoft certificate when they get 85 in this unit");
unit2.setWeight(20);
uList.add(unit2);
unit3.setMarks(80);
unit3.setUnitName("Painting");
unit3.setDescription(
"Students' productions can be displayed on the school website when they can get 85 in this unit.");
unit3.setWeight(10);
uList.add(unit3);
Unit unit4 = new Unit();
unit4.setMarks(0);
unit4.setUnitName("History");
unit4.setDescription("");
unit4.setWeight(20);
uList.add(unit4);
Unit unit5 = new Unit();
unit5.setMarks(0);
unit5.setUnitName("Final");
unit5.setDescription("The student has the opportunity to apply for a scholarship when the final grade is HD.");
unit5.setWeight(100);
uList.add(unit5);
this.uList = uList;
System.out.println("Unit List Created ...");
}
public void setGradeData() {
List<GradeData> gradeList = new ArrayList<GradeData>();
GradeData grade = new GradeData();
grade.setMarks(85);
grade.setGrade("HD");
grade.setNote("");
gradeList.add(grade);
GradeData grade1 = new GradeData();
grade1.setMarks(75);
grade1.setGrade("D");
grade1.setNote("");
gradeList.add(grade1);
GradeData grade2 = new GradeData();
grade2.setMarks(65);
grade2.setGrade("C");
grade2.setNote("");
gradeList.add(grade2);
GradeData grade3 = new GradeData();
grade3.setMarks(50);
grade3.setGrade("P");
grade3.setNote("");
gradeList.add(grade3);
GradeData grade4 = new GradeData();
grade4.setMarks(49);
grade4.setGrade("F");
grade4.setNote("Students need to enrol this unit next semester"); // 4
gradeList.add(grade4);
GradeData grade7 = new GradeData();
grade7.setMarks(0);
grade7.setGrade("NOT ATTEND");
grade7.setNote("Students need to explain their absence and enrol this unit next semester."); // 5
gradeList.add(grade7);
this.gradeList = gradeList;
System.out.println("Grade List Created ...");
}
public void setFeePlanData() {
List<FeePlan> feeList = new ArrayList<FeePlan>();
FeePlan fee = new FeePlan();
fee.setUnitCode(4483);
fee.setUnitName("Maths");
fee.setFeePlanA(1000);
fee.setFeePlanB(1200);
feeList.add(fee);
FeePlan fee1 = new FeePlan();
fee1.setUnitCode(4485);
fee1.setUnitName("Biology");
fee1.setFeePlanA(1580);
fee1.setFeePlanB(1780);
feeList.add(fee1);
FeePlan fee2 = new FeePlan();
fee2.setUnitCode(4486);
fee2.setUnitName("Information Technology");
fee2.setFeePlanA(1580);
fee2.setFeePlanB(1780);
feeList.add(fee2);
FeePlan fee3 = new FeePlan();
fee3.setUnitCode(4487);
fee3.setUnitName("Painting");
fee3.setFeePlanA(1580);
fee3.setFeePlanB(1780);
feeList.add(fee3);
FeePlan fee4 = new FeePlan();
fee4.setUnitCode(4488);
fee4.setUnitName("History");
fee4.setFeePlanA(1000);
fee4.setFeePlanB(1200);
feeList.add(fee4);
FeePlan fee5 = new FeePlan();
fee5.setUnitCode(4489);
fee5.setUnitName("Ecology");
fee5.setFeePlanA(1000);
fee5.setFeePlanB(1200);
feeList.add(fee5);
FeePlan fee6 = new FeePlan();
fee6.setUnitCode(8873);
fee6.setUnitName("Accounting");
fee6.setFeePlanA(1000);
fee6.setFeePlanB(1200);
feeList.add(fee6);
FeePlan fee7 = new FeePlan();
fee7.setUnitCode(8872);
fee7.setUnitName("Chief");
fee7.setFeePlanA(1580);
fee7.setFeePlanB(1780);
feeList.add(fee7);
FeePlan fee8 = new FeePlan();
fee8.setUnitCode(8871);
fee8.setUnitName("Spanish");
fee8.setFeePlanA(1200);
fee8.setFeePlanB(1200);
feeList.add(fee8);
this.feeList = feeList;
System.out.println("Fee Plan Created ...");
}
public void setStudentList() {
List<Student> studentList = new ArrayList<Student>();
Student students = new Student();
students.setStudentFirstName("Saurabh");
students.setStudentLastName("Singh");
students.setStudentId("s43123");
students.setStudentPassword("North2020");
studentList.add(students);
Student students1 = new Student();
students1.setStudentFirstName("vijay");
students1.setStudentLastName("Singh");
students1.setStudentId("u123");
students1.setStudentPassword("u123");
studentList.add(students1);
Student students2 = new Student();
students2.setStudentFirstName("Ajay");
students2.setStudentLastName("Thakur");
students2.setStudentId("u32910");
students2.setStudentPassword("u32910");
studentList.add(students2);
this.studentList = studentList;
System.out.println("Student List Created ...");
}
public List<Unit> getuList() {
return uList;
}
public List<GradeData> getGradeList() {
return gradeList;
}
public List<FeePlan> getFeeList() {
return feeList;
}
public List<Student> getStudentList() {
return studentList;
}
public boolean isUserExist(String id,String pass) {
List<Student> studentList = this.studentList;
for (Student s : studentList) {
if (s.getStudentId().equals(id)==true && s.getStudentPassword().equals(pass) == true)
return true;
}
return false;
}
public static void main(String args[])
{
MainClass mainObj = new MainClass();
mainObj.setUnitListData();
mainObj.setStudentList();
mainObj.setGradeData();
mainObj.setFeePlanData();
myObj = new Scanner(System.in);
while(true)
{
System.out.print("\n\nEnter your Id (Press Z for Exit) : ");
String id = myObj.nextLine();
if(id.equals("Z" ))
break;
System.out.print("\n\nEnter your Password :");
String pass = myObj.nextLine();
boolean check = mainObj.isUserExist(id,pass);
if(check == false)
{
System.out.println("Invalid User Id !! ");
break;
}
else
{
System.out.println("\n\n !!! User Login Success !!! \n\n");
System.out.print("\nYour Maths Marks : ");
int maths = myObj.nextInt();
System.out.print("\nYour Biology Marks : ");
int biology = myObj.nextInt();
System.out.print("\nYour IT Marks : ");
int it = myObj.nextInt();
System.out.print("\nYour Painting Marks : ");
int painting = myObj.nextInt();
System.out.print("\nYour History Marks : ");
int history = myObj.nextInt();
double final_result =((double)( maths + biology+ it + painting + history )/500)*100;
System.out.println("\n\nFinal Result : "+final_result);
String final_grade="Not attend";
List<Unit> unitList = mainObj.getuList();
List<GradeData> gradeList = mainObj.getGradeList();
List<FeePlan> feeList = mainObj.getFeeList();
for(GradeData g : gradeList)
{
if(g.getMarks() < final_result)
{
final_grade = g.getGrade();
break;
}
}
System.out.println("Final Grade : "+ final_grade);
int final_result2 = 0;
if(final_grade == "HD")
{
final_result = 100;
}
for(Unit u : unitList)
{
if(u.getUnitName().equals("Maths") && u.getMarks() < maths)
System.out.println(u.getDescription());
else if(u.getUnitName().equals("Biology") && u.getMarks() < biology)
System.out.println(u.getDescription());
else if(u.getUnitName().equals("IT") && u.getMarks() < it)
System.out.println(u.getDescription());
else if(u.getUnitName().equals("Painting") && u.getMarks() < final_result)
System.out.println(u.getDescription());
else if(u.getUnitName().equals("Hiostory") && u.getMarks() < history)
System.out.println(u.getDescription());
else if(u.getUnitName().equals("Final") && u.getMarks() < final_result2)
System.out.println(u.getDescription());
}
if(final_grade == "Not Attend")
System.out.println("Students need to explain their absence and enrol this unit next semester.");
}
}
System.out.println("\n\nThank You !!");
}
}