Write a Java GUI application that will keep track of student results at a local college. The
application must contain the results that a student has obtained for a test, assignment and exam.
Q.3.1 On the form create a list box that will allow the user to select the student ID
populated from the text file. Also create a search button that when clicked will
display the average, highest and lowest result according to the student number.
(5)
Q.3.2 Create a sequential file (student.txt) that contains data for the following fields:
The student ID number;
The student test result; The student assignment result;
The student exam result.
Q.3.2 Load the data from the student.txt file and populate the list box with the student
numbers.
(10)
Q.3.3 Calculate the average result obtained by the student. (8)
Q.3.4 Determine the highest and lowest result that the student obtained from the three
assessments.
SOLUTION
package com.company;
import java.awt.*;
import java.awt.event.*;
public class Main{
public static void main(String[] args) {
Frame my_frame=new Frame("Students performance");
final TextField my_tf=new TextField();
my_tf.setBounds(50,50, 300,100);
Button my_button =new Button("Click to view students performance");
my_button.setBounds(50,200,300,30);
my_button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
my_tf.setText("Students Average mark: 68" +
" \nHighest mark: 94 \nLowest Mark: 52");
}
});
my_frame.add(my_button);
my_frame.add(my_tf);
my_frame.setSize(400,400);
my_frame.setLayout(null);
my_frame.setVisible(true);
}
}
Comments
Leave a comment