import java.awt.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class ProjectX extends JFrame implements ChangeListener,
ActionListener
{
static int ch = 0;
static String ln = "--------------------------------";
DataInputStream inputData = new DataInputStream(System.in);
private Registration studentDetails = new Registration();
int highscore = studentDetails.gethighscore();
int passingMarks = studentDetails.getpassingMarks();
int firstClass = studentDetails.getFirstClass();
int secondClass = studentDetails.getSecondClass();
JTabbedPane tabbedPane = new JTabbedPane();
JLabel statusLabel = new JLabel();
JLabel titleLabel = new JLabel("Student Software Beta Edition");
JPanel addStudentPanel = new JPanel();
JTextField studentName = new JTextField();
JTextField physicsMarks = new JTextField();
JTextField biologyMarks = new JTextField();
JTextField mathsMarks = new JTextField();
JButton submitDetails = new JButton("Submit Details");
JPanel studentDetailsPanel = new JPanel();
JTextField studentID1 = new JTextField();
JTextArea studentInfo = new JTextArea();
JButton submitID1 = new JButton("Submit ID");
JPanel studentGradePanel = new JPanel();
JTextField studentID2 = new JTextField();
JTextArea studentGrade = new JTextArea();
JButton submitID2 = new JButton("Submit ID");
JPanel numberPassedPanel = new JPanel();
JTextArea studentPassed = new JTextArea();
JPanel classTopperPanel = new JPanel();
JTextArea studentTopper = new JTextArea();
public ProjectX(String title)
{
super(title);
setResizable(true);
setSize(500,500);
submitDetails.addActionListener(this);
submitID1.addActionListener(this);
submitID2.addActionListener(this);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(titleLabel,"North");
tabbedPane.addTab("Add Student",addStudentPanel);
addStudentPanel.setLayout(new GridLayout(8,2,5,5));
addStudentPanel.add(new JLabel("Student Name: "));
addStudentPanel.add(studentName);
addStudentPanel.add(new JLabel("Physics Marks: "));
addStudentPanel.add(physicsMarks);
addStudentPanel.add(new JLabel("Biology Marks: "));
addStudentPanel.add(biologyMarks);
addStudentPanel.add(new JLabel("Maths Marks: "));
addStudentPanel.add(mathsMarks);
addStudentPanel.add(submitDetails);
tabbedPane.addTab("Student Details",studentDetailsPanel);
studentDetailsPanel.add(new JLabel("Enter Student ID: "));
studentDetailsPanel.add(studentID1);
studentDetailsPanel.add(submitID1);
studentDetailsPanel.add(new JLabel("Student Details:"));
studentDetailsPanel.add(studentInfo);
tabbedPane.addTab("Student Grade",studentGradePanel);
studentGradePanel.setLayout(new GridLayout(5,2,5,5));
studentGradePanel.add(new JLabel("Enter Student ID: "));
studentGradePanel.add(studentID2);
studentGradePanel.add(submitID2);
studentGradePanel.add(new JLabel("Student Grade:"));
studentGradePanel.add(studentGrade);
tabbedPane.addTab("Passed Student",numberPassedPanel);
numberPassedPanel.setLayout(new GridLayout(2,2,5,5));
numberPassedPanel.add(new JLabel("Number of Student Passed: "));
numberPassedPanel.add(studentPassed);
tabbedPane.addTab("Class Topper",classTopperPanel);
classTopperPanel.setLayout(new GridLayout(2,2,5,5));
classTopperPanel.add(new JLabel("Here are the class Toppers: "));
classTopperPanel.add(studentTopper);
tabbedPane.addChangeListener(this);
getContentPane().add(tabbedPane,"Center");
statusLabel.setText("Status: Normal");
getContentPane().add(statusLabel,"South");
setVisible(true);
}
public static void main(String args[])
{
ProjectX outputScreen = new ProjectX("Case Study");
}
public String setStudentInfo()
{
int id = studentDetails.addStudent(studentName.getText(),Integer.parseInt(physicsMarks.getText()),Integer.parseInt(biologyMarks.getText()),Integer.parseInt(mathsMarks.getText()));
return(" "+ln+"Record Created For " + studentName +" "+"Student ID: " + id+" "+ln);
}
public String getStudentInfo()
{
int id = Integer.parseInt(studentID1.getText());
if(studentDetails.getStudentDetails(id))
return(" "+ln+"Student Details"+ln+"Student ID:" + " " + id + " "+"Student Name:" + "" + studentDetails.studentName + " "+ "Physics Marks:" + " " + studentDetails.physicsMarks + " " +"Biology Marks:" + " " + studentDetails.biologyMarks + "" +"Maths Marks:" + " " + studentDetails.mathsMarks + " "+ln);
else
return("Records Not Found for ID " + id);
}
public String getStudentGrade()
{
int id = Integer.parseInt(studentID2.getText());
studentDetails.getStudentDetails(id);
String grade;
if(studentDetails.studentName == null)
{
System.out.println("Records Not Found for ID " + id);
return null;
}
if(studentDetails.physicsMarks < passingMarks ||studentDetails.biologyMarks < passingMarks || studentDetails.mathsMarks <passingMarks)
{
grade = "Failed";
}
else
{
int avgMarks = (studentDetails.physicsMarks +studentDetails.biologyMarks + studentDetails.mathsMarks)/3;
if(avgMarks >= passingMarks && avgMarks < secondClass) grade = "PassClass";
else if(avgMarks >= secondClass && avgMarks < firstClass) grade ="Second Class";
else if(avgMarks >= firstClass && avgMarks < highscore) grade = "FirstClass";
else grade = "Distinction";
}
return(ln + "Grade For " + studentDetails.studentName + " is " + grade+ "" + ln);
}
public String getNumberPasses()
{
int lastID = Registration.getNextID() -1;
boolean passed = true;
int numberPassed = 0;
for(int id = 1; id <= lastID; id++)
{
studentDetails.getStudentDetails(id);
if(studentDetails.physicsMarks >= passingMarks &&studentDetails.biologyMarks >= passingMarks && studentDetails.mathsMarks >=passingMarks) numberPassed++;
}
return(ln + "Number of Student Passed: " + numberPassed + " " +ln);
}
public String getClassTopper()
{
int lastID = Registration.getNextID() -1;
String classTopper;
StringBuffer buffer = new StringBuffer(500);
int topMarks = 0;
for(int id = 1; id <= lastID; id++)
{
studentDetails.getStudentDetails(id);
int studentMarks = studentDetails.physicsMarks +studentDetails.biologyMarks + studentDetails.mathsMarks;
if(studentMarks > topMarks) topMarks = studentMarks;
}
buffer.append(ln + "Student Having Top Marks: ");
for(int id = 1; id <= lastID; id++)
{
studentDetails.getStudentDetails(id);
int studentMarks = studentDetails.physicsMarks +studentDetails.biologyMarks + studentDetails.mathsMarks;
if(studentMarks == topMarks)
{
buffer.append(studentDetails.studentName + " Having Total Marks: " +topMarks + " ");
}
}
buffer.append(ln);
return(buffer.toString());
}
public void stateChanged(ChangeEvent e)
{
switch(tabbedPane.getSelectedIndex())
{
case 3: studentPassed.setText(getNumberPasses());
break;
case 4: studentTopper.setText(getClassTopper());
break;
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == submitID1)
{
studentInfo.setText(getStudentInfo());
}
else if(e.getSource() == submitID2)
{
studentGrade.setText(getStudentGrade());
}
if(e.getSource() == submitDetails)
{
setStudentInfo();
}
}
}
//Registration Class
class Registration
{
private int highscore = 90;
private int passingMarks = 35;
private int firstClass = 65;
private int secondClass = 45;
private static String idFile = "id.dat";
private static String studentFile = "studentfile.dat";
public int id;
public String studentName;
public int physicsMarks;
public int biologyMarks;
public int mathsMarks;
public int addStudent(String studentName, int physicsMarks, int biologyMarks, int mathsMarks)
{
int id = 0;
try
{
FileWriter fileOutput = new FileWriter(Registration.studentFile,true);
id = Registration.getNextID();
String buffer = id + "|" + studentName + "|" + physicsMarks + "|" + biologyMarks + "|" + mathsMarks + " ";
fileOutput.write(buffer);
fileOutput.close();
Registration.setID(id);
}
catch(IOException e)
{
System.err.println(e.toString());
System.exit(1);
}
return id;
}
//Function to get the details of a student given the ID
public boolean getStudentDetails(int id)
{
try
{
FileReader fileInput = new FileReader(Registration.studentFile);
BufferedReader br = new BufferedReader(fileInput);
{
String str;
while((str = br.readLine()) != null)
{
StringTokenizer fields = new StringTokenizer(str,"|");
if(Integer.parseInt(fields.nextToken()) == id)
{
this.id = id;
this.studentName = fields.nextToken();
this.physicsMarks = Integer.parseInt(fields.nextToken());
this.biologyMarks = Integer.parseInt(fields.nextToken());
this.mathsMarks = Integer.parseInt(fields.nextToken());
return true;
}
}
}
}
catch(IOException e)
{
System.err.println(e.toString());
System.exit(1);
}
return false;
}
public int gethighscore()
{
return highscore;
}
public int getpassingMarks()
{
return passingMarks;
}
public int getFirstClass()
{
return firstClass;
}
public int getSecondClass()
{
return secondClass;
}
//Function to get the next ID available
public static int getNextID()
{
int id = 0;
try
{
RandomAccessFile studentIDFile = new
RandomAccessFile(Registration.idFile,"rw");
if(studentIDFile.length() == 0)
{
id = 0;
}
else id = studentIDFile.readInt();
id++;
studentIDFile.close();
}
catch(IOException e)
{
System.err.println(e.toString());
System.exit(1);
}
return id;
}
//Function to Store current ID in a file
public static void setID(int id)
{
try
{
RandomAccessFile studentIDFile = new
RandomAccessFile(Registration.idFile,"rw");
studentIDFile.seek(0);
studentIDFile.writeInt(id);
studentIDFile.close();
}
catch(IOException e)
{
System.err.println(e.toString());
System.exit(1);
}
}
}
Wednesday
//
Labels:
JAVA PROJECTS
//
0
comments
//
0 comments to "MANAGEMENT OF SCHOOL RECORDS USING JAVA"
Powered by Blogger.
Blog Archive
-
▼
2011
(50)
-
▼
August
(12)
- INTRODUCTION TO JAVA
- ABSTRACTION
- INHERITANCE
- ENCAPSULATION
- SIMPLE JAVA PROGRAM
- BABYLONIAN METHOD FOR DETERMINING A SQUARE ROO...
- TRIGONOMETRIC FUNCTIONS CALCULATED USING MCLAUREN ...
- PROJECT ON RESERVATION
- CALCULATOR USING JAVA
- MANAGEMENT OF SCHOOL RECORDS USING JAVA
- MULTITHREADED MATRIX MULTIPLICATION IN JAVA
- PROJECT ON LIBRARY SYSTEM IN JAVA
-
▼
August
(12)
Post a Comment