473,468 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

comp. sci project... NEED OF DESPERATE HELP

2 New Member
hi guys! so im basically editting my post i made earlier as it wznt as specific..
i have to make a program that basically ranks students by their cumulative gpa. the student's info is on a csv file written in a format like this, "name,bday,sex,9-1,9-2,10-1,10-2.....,cumulative". my question is, should i read this whole line nd jz use the cumulative data (im not sure how to do dat:/) or make a separate class nd make an array (for loop nd stuff) btw this program is a portion of a major program, basically a student ranker (some may know the program gradequick?) which has info abt da students freshmen gpa to senior gpa. i was able to add the student's info into my program nd saving the list as a csv file. but now im kinda stuck on the ranking part :/ please help me! heres a code for my program.. i hope you understand it.. oh and another thing is, i was able to recall the student that i wanted to edit, but after changing the data, if i press the save button again, instead of changing the original student, it saves it as a new student.. how do i change this..

import java.io.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.*;
import java.awt.event.*;

public class Create extends JFrame
{

Container mainPane = getContentPane();
private JButton editButton = new JButton("Edit Student");
private JButton viewButton = new JButton("View Students");
private JButton rankButton = new JButton("View Rank");
private JButton saveButton = new JButton("Save");
private JButton resetButton = new JButton("Reset");
private JButton quitButton = new JButton("Quit");
private JTextField nameField = new JTextField();
private JTextField idField = new JTextField();
private JTextField bdayField = new JTextField();
private JTextField sexField = new JTextField();
private JTextField nine1Field = new JTextField();
private JTextField nine2Field = new JTextField();
private JTextField ten1Field = new JTextField();
private JTextField ten2Field = new JTextField();
private JTextField elev1Field = new JTextField();
private JTextField elev2Field = new JTextField();
private JTextField twelve1Field = new JTextField();
private JTextField twelve2Field = new JTextField();
private JTextArea outputArea = new JTextArea();

private BufferedReader inFile;
private PrintStream p;
private int num, id, i, id1, rank, counter;
private double q, w, e, r, t, y, u, o, cum;
private double[] cumu;
private String name, bday, sex, f, ques;
private Data[] students;
private Data student;


public Create(){

super("GPA Checker");

gradeQuick();

}

public void gradeQuick(){

mainPane.setLayout(new GridLayout(1,3));
JPanel leftPane = new JPanel(new GridLayout(2,2));
JPanel midPane = new JPanel(new GridLayout(7,2));
JPanel rightPane = new JPanel(new GridLayout(1,1));
JPanel midSubPane1 = new JPanel(new GridLayout(1,1));
JPanel midSubPane2 = new JPanel(new GridLayout(1,1));
JPanel midSubPane3 = new JPanel(new GridLayout(1,1));
JPanel midSubPane4 = new JPanel(new GridLayout(1,1));
JPanel midSubPane5 = new JPanel(new GridLayout(1,1));
JPanel midSubPane6 = new JPanel(new GridLayout(1,1));
JPanel midSubPane7 = new JPanel(new GridLayout(1,1));
JPanel midSubPane8 = new JPanel(new GridLayout(1,1));
JPanel midSubPane9 = new JPanel(new GridLayout(1,1));
JPanel midSubPane10 = new JPanel(new GridLayout(1,1));
JPanel midSubPane11 = new JPanel(new GridLayout(1,1));
JPanel midSubPane12 = new JPanel(new GridLayout(1,1));

saveButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent z){
try{
counter = 0;
String[] line;
BufferedReader inFile2 = new BufferedReader(new FileReader("students.csv"));
inFile2.readLine();
while(inFile2.ready()){
inFile2.readLine();
counter++;
}
inFile2.close();
line = new String[counter];
students = new Data[counter];
BufferedReader inFile = new BufferedReader(new FileReader("students.csv"));
inFile.readLine();
for(int i=0;i<counter;i++){
line[i] = inFile.readLine();
}
inFile.close();
p = new PrintStream(new FileOutputStream("students.csv"));
p.println("Name , ID , Gender , Birthday, 9-1 , 9-2 , 10-1 , 10-2 , 11 -1 , 11-2 , 12-1 , 12-2 , Cumulative");
for(int i=0;i<counter;i++){
p.println(line[i]);
}
name = nameField.getText();
id = Integer.parseInt(idField.getText());
sex = sexField.getText();
bday = bdayField.getText();
q = Double.parseDouble(nine1Field.getText());
w = Double.parseDouble(nine2Field.getText());
e = Double.parseDouble(ten1Field.getText());
r = Double.parseDouble(ten2Field.getText());
t = Double.parseDouble(elev1Field.getText());
y = Double.parseDouble(elev2Field.getText());
u = Double.parseDouble(twelve1Field.getText());
o = Double.parseDouble(twelve2Field.getText());
if(o>0){
cum= ((q+w+e+r+t+y+u+o)/8);
}
else if(u>0){
cum= ((q+w+e+r+t+y+u)/7);
}
else if(y>0){
cum= ((q+w+e+r+t+y)/6);
}
else if(t>0){
cum= ((q+w+e+r+t)/5);
}
else if(r>0){
cum= ((q+w+e+r)/4);
}
else if(e>0){
cum= ((q+w+e)/3);
}
else if(w>0){
cum= ((q+w)/2);
}
else if(q>0){
cum= ((q)/1);
}
// students[counter] = new Data(name, id, sex, bday, q, w, e, r, t, y, u, o, cum);
p.println(name+","+ id+","+ sex+","+ bday+","+ q+","+ w+","+ e+","+ r+","+ t+","+ y+","+ u+","+ o+","+ cum);




// p.println(students[counter].getName()+" , "+students[counter].getID()+" , "+students[counter].getSex()+" , "+students[counter].getBday()+" , " +students[counter].get91()+" , " +students[counter].get92()+" , "+students[counter].get101()+" , "+students[counter].get102()+" , "+students[counter].get111()+" , "+students[counter].get112()+" , "+students[counter].get121()+" , "+students[counter].get122()+" , "+students[counter].getCum());
p.close();
}catch(IOException e){
System.err.println("Error");
}
}//end of actionPerformed
}//end of inner class
);//end of argument

editButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
String[] blah = new String[12];
f = JOptionPane.showInputDialog("Enter ID Number of student you wish to edit");
id1 = Integer.parseInt(f);
int comma;
int id2 = 0;
String txt,txt2;
BufferedReader inFile3 = new BufferedReader(new FileReader("students.csv"));
inFile3.readLine();
do{
txt = inFile3.readLine();
comma = txt.indexOf(",");
txt2 = txt.substring(comma+1,comma+6);
id2 = Integer.parseInt(txt2);
}while(id1!=id2);
for(int index=0;index<blah.length;index++){
comma = txt.indexOf(",");
blah[index] = txt.substring(0,comma);
txt = txt.substring(comma+1);
}
nameField.setText(blah[0]);
idField.setText(blah[1]);
sexField.setText(blah[2]);
bdayField.setText(blah[3]);
nine1Field.setText(blah[4]);
nine2Field.setText(blah[5]);
ten1Field.setText(blah[6]);
ten2Field.setText(blah[7]);
elev1Field.setText(blah[8]);
elev2Field.setText(blah[9]);
twelve1Field.setText(blah[10]);
twelve2Field.setText(blah[11]);
// student = new Data(
}
catch(IOException e4){
}

}//end of actionPerformed
}//end of inner class
);//end of argument

viewButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e1){

}//end of actionPerformed
}//end of inner class
);//end of argument

rankButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e1){
IM STUCK HERE :S
}
}//end of actionPerformed
}//end of inner class
);//end of argument

saveButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e1){
}//end of actionPerformed
}//end of inner class
);//end of argument

resetButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e1){
setVisible(false);
new Create();
}//end of actionPerformed
}//end of inner class
);//end of argument

quitButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e1){
Create.this.dispose();
System.exit(0);
}//end of actionPerformed
}//end of inner class
);//end of argument


leftPane.setBorder(BorderFactory.createTitledBorde r("Program Options"));
midPane.setBorder(BorderFactory.createTitledBorder ("Input"));
rightPane.setBorder(BorderFactory.createTitledBord er("Output"));
leftPane.add(viewButton);
leftPane.add(rankButton);
leftPane.add(resetButton);
leftPane.add(quitButton);
midSubPane1.setBorder(BorderFactory.createTitledBo rder("Name(Last. First)"));
midSubPane2.setBorder(BorderFactory.createTitledBo rder("ID #"));
midSubPane3.setBorder(BorderFactory.createTitledBo rder("Birthday(MM/DD/YY)"));
midSubPane4.setBorder(BorderFactory.createTitledBo rder("Sex(M/F)"));
midSubPane5.setBorder(BorderFactory.createTitledBo rder("Grade 9 - 1"));
midSubPane6.setBorder(BorderFactory.createTitledBo rder("Grade 9 - 2"));
midSubPane7.setBorder(BorderFactory.createTitledBo rder("Grade 10 - 1"));
midSubPane8.setBorder(BorderFactory.createTitledBo rder("Grade 10 - 2"));
midSubPane9.setBorder(BorderFactory.createTitledBo rder("Grade 11 - 1"));
midSubPane10.setBorder(BorderFactory.createTitledB order("Grade 11 - 2"));
midSubPane11.setBorder(BorderFactory.createTitledB order("Grade 12 - 1"));
midSubPane12.setBorder(BorderFactory.createTitledB order("Grade 12 - 2"));
midSubPane1.add(nameField);
midSubPane2.add(idField);
midSubPane3.add(bdayField);
midSubPane4.add(sexField);
midSubPane5.add(nine1Field);
midSubPane6.add(nine2Field);
midSubPane7.add(ten1Field);
midSubPane8.add(ten2Field);
midSubPane9.add(elev1Field);
midSubPane10.add(elev2Field);
midSubPane11.add(twelve1Field);
midSubPane12.add(twelve2Field);
midPane.add(midSubPane1);
midPane.add(midSubPane2);
midPane.add(midSubPane3);
midPane.add(midSubPane4);
midPane.add(midSubPane5);
midPane.add(midSubPane6);
midPane.add(midSubPane7);
midPane.add(midSubPane8);
midPane.add(midSubPane9);
midPane.add(midSubPane10);
midPane.add(midSubPane11);
midPane.add(midSubPane12);
midPane.add(editButton);
midPane.add(saveButton);
rightPane.add(new JScrollPane(outputArea));
mainPane.add(leftPane);
mainPane.add(midPane);
mainPane.add(rightPane);
setContentPane(mainPane);
setLocation(10,10);
setSize(800,500);
setVisible(true);

}
}
Mar 4 '08 #1
0 1209

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
We've developed a content management system that we donate to the public domain (via a Creative Commons declaration) at www.publicdomainsoftware.org. Our cms has an emphasis on weblogs, though we...
17
by: EkteGjetost | last post by:
This is definitely not the smart thing to do as far as my learning goes, but desperate situations call for desperate measures. The final lab for my introduction to C programming class is due...
22
by: dw | last post by:
Please help some desperate developers!! We need to create an ASP.NET project via VS.NET 2003 on a networked Win 2003 server that we use for testing, but it keeps generating an error: "The Web...
4
by: TimC | last post by:
I hope someone can help - I am getting desperate! I have promised to do some work for someone developing an ASP.NEt application. I have VS Studio 2002 installed on my pc which is running...
4
by: Smoothcoder | last post by:
Hi, there, smart guys! I have an AMD 64 3000+ based system, with Windows XP Professional on it; I recently installed Visual Studio 2003 Enterprise Architect; I created a new C# ASP.NET Web...
1
by: Daniel Knöpfel | last post by:
Hello Im triying to create an installer using ClickOnce and visual studio 2005. This works fine on my computer, but as soon as i start the created installer on another pc I get the following...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
2
by: bsdixon21222 | last post by:
Ok, so I have a project that I need to do with C++. I have finished all of it, but one part. One of the fuctions (filling the array) needs to open a file for reading ( (7,16,43,23,53) etc) and output...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.