Академический Документы
Профессиональный Документы
Культура Документы
MALAYSIA
____________________________________
COLLEGE OF ARTS AND SCIENCES
STIA 1023
ADVANCE PROGRAMMING
(Group D)
public Student(){
totalMarks=0;
grade="";
}
public void setStudent(String name,String matricNo,String gender,String
college,String level){
this.name=name;
this.matricNo=matricNo;
this.gender=gender;
this.college=college;
this.level=level;
}
public void setMark(double totalQuizes,double totalAssignment,double
totalProject, double totalTest,double totalFinal){
this.totalQuizes=totalQuizes;
this.totalAssignment=totalAssignment;
this.totalProject=totalProject;
this.totalTest=totalTest;
this.totalFinal=totalFinal;
}
public void computeTotalMarks(){
totalMarks = totalQuizes + totalAssignment+ totalTest+totalFinal;
}
1. By using the solution of the previous lab exercise (Lab Exercise 5), you are required
to modify the GUI program so that the concepts of menu and event-handing can be
applied. The program to be developed should make use the above Student class by
calling the appropriate method(s) to accomplish certain tasks. Declare an object
reference of the type Student as a data member of the class and instantiate the
object of Student in a constructor. Please follow the following instructions:
a. Add menu and menu item as shown below:
b. When the “Calculate Grade” button is pressed, the program will display a grade in
the text field that is provided on the interface. The grade is defined based on
summation of the mark of quizzes, assignments, mid test, project and final
exam. Appropriate method (s) from the above Student class should be
invoked to manage this task.
c. When the user presses “Reset” button, all text fields will be reset.
d. When the “Display Details” button is pressed, the program will display a student’s
details in the text area as shown in the figure below. The student’s details are
captured from the interface of the application based on the user input. You
are also required to invoke appropriate method (s) from the above Student
class to manage this task.
e. When the user presses “Exit” menu item or “Exit” button, the program will
eventually be terminated.
Answer:
//data member
Student stud;
double quiz=Double.parseDouble(txtQuiz.getText());
double asg=Double.parseDouble(txtAssignment.getText());
double mid=Double.parseDouble(txtMidExam.getText());
double project=Double.parseDouble(txtProject.getText());
double fin=Double.parseDouble(txtFinal.getText());
stud.setMark(quiz, asg, project, mid, fin);
stud.computeGrade();
String grade=stud.getGrade();
txtGrade.setText(grade);
}
private void btnDisplayActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
String name=txtName.getText();
String matric=txtMatric.getText();
String gender=””;
if(rdMale.isSelected()==true)
gender="Male";
else
gender="Female";
String level=””;
if(rdUnderGraduate.isSelected()==true)
level="Undergraduate";
else
level="Postgraduate";
String college=(String)cboCollege.getSelectedItem();
stud.setInfo(name, matric, gender, college,level);
txtOutput.setText(stud.toString());
}