473,810 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ 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.....,cumulati ve". 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.eve nt.*;
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.setLay out(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.addA ctionListener(n ew ActionListener( ){
public void actionPerformed (ActionEvent z){
try{
counter = 0;
String[] line;
BufferedReader inFile2 = new BufferedReader( new FileReader("stu dents.csv"));
inFile2.readLin e();
while(inFile2.r eady()){
inFile2.readLin e();
counter++;
}
inFile2.close() ;
line = new String[counter];
students = new Data[counter];
BufferedReader inFile = new BufferedReader( new FileReader("stu dents.csv"));
inFile.readLine ();
for(int i=0;i<counter;i ++){
line[i] = inFile.readLine ();
}
inFile.close();
p = new PrintStream(new FileOutputStrea m("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.getTe xt();
id = Integer.parseIn t(idField.getTe xt());
sex = sexField.getTex t();
bday = bdayField.getTe xt();
q = Double.parseDou ble(nine1Field. getText());
w = Double.parseDou ble(nine2Field. getText());
e = Double.parseDou ble(ten1Field.g etText());
r = Double.parseDou ble(ten2Field.g etText());
t = Double.parseDou ble(elev1Field. getText());
y = Double.parseDou ble(elev2Field. getText());
u = Double.parseDou ble(twelve1Fiel d.getText());
o = Double.parseDou ble(twelve2Fiel d.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(stude nts[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(IOExcept ion e){
System.err.prin tln("Error");
}
}//end of actionPerformed
}//end of inner class
);//end of argument

editButton.addA ctionListener(n ew ActionListener( ){
public void actionPerformed (ActionEvent e){
try{
String[] blah = new String[12];
f = JOptionPane.sho wInputDialog("E nter ID Number of student you wish to edit");
id1 = Integer.parseIn t(f);
int comma;
int id2 = 0;
String txt,txt2;
BufferedReader inFile3 = new BufferedReader( new FileReader("stu dents.csv"));
inFile3.readLin e();
do{
txt = inFile3.readLin e();
comma = txt.indexOf("," );
txt2 = txt.substring(c omma+1,comma+6) ;
id2 = Integer.parseIn t(txt2);
}while(id1!=id2 );
for(int index=0;index<b lah.length;inde x++){
comma = txt.indexOf("," );
blah[index] = txt.substring(0 ,comma);
txt = txt.substring(c omma+1);
}
nameField.setTe xt(blah[0]);
idField.setText (blah[1]);
sexField.setTex t(blah[2]);
bdayField.setTe xt(blah[3]);
nine1Field.setT ext(blah[4]);
nine2Field.setT ext(blah[5]);
ten1Field.setTe xt(blah[6]);
ten2Field.setTe xt(blah[7]);
elev1Field.setT ext(blah[8]);
elev2Field.setT ext(blah[9]);
twelve1Field.se tText(blah[10]);
twelve2Field.se tText(blah[11]);
// student = new Data(
}
catch(IOExcepti on e4){
}

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

viewButton.addA ctionListener(n ew ActionListener( ){
public void actionPerformed (ActionEvent e1){

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

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

saveButton.addA ctionListener(n ew ActionListener( ){
public void actionPerformed (ActionEvent e1){
}//end of actionPerformed
}//end of inner class
);//end of argument

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

quitButton.addA ctionListener(n ew ActionListener( ){
public void actionPerformed (ActionEvent e1){
Create.this.dis pose();
System.exit(0);
}//end of actionPerformed
}//end of inner class
);//end of argument


leftPane.setBor der(BorderFacto ry.createTitled Border("Program Options"));
midPane.setBord er(BorderFactor y.createTitledB order("Input")) ;
rightPane.setBo rder(BorderFact ory.createTitle dBorder("Output "));
leftPane.add(vi ewButton);
leftPane.add(ra nkButton);
leftPane.add(re setButton);
leftPane.add(qu itButton);
midSubPane1.set Border(BorderFa ctory.createTit ledBorder("Name (Last. First)"));
midSubPane2.set Border(BorderFa ctory.createTit ledBorder("ID #"));
midSubPane3.set Border(BorderFa ctory.createTit ledBorder("Birt hday(MM/DD/YY)"));
midSubPane4.set Border(BorderFa ctory.createTit ledBorder("Sex( M/F)"));
midSubPane5.set Border(BorderFa ctory.createTit ledBorder("Grad e 9 - 1"));
midSubPane6.set Border(BorderFa ctory.createTit ledBorder("Grad e 9 - 2"));
midSubPane7.set Border(BorderFa ctory.createTit ledBorder("Grad e 10 - 1"));
midSubPane8.set Border(BorderFa ctory.createTit ledBorder("Grad e 10 - 2"));
midSubPane9.set Border(BorderFa ctory.createTit ledBorder("Grad e 11 - 1"));
midSubPane10.se tBorder(BorderF actory.createTi tledBorder("Gra de 11 - 2"));
midSubPane11.se tBorder(BorderF actory.createTi tledBorder("Gra de 12 - 1"));
midSubPane12.se tBorder(BorderF actory.createTi tledBorder("Gra de 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.ad d(elev2Field);
midSubPane11.ad d(twelve1Field) ;
midSubPane12.ad d(twelve2Field) ;
midPane.add(mid SubPane1);
midPane.add(mid SubPane2);
midPane.add(mid SubPane3);
midPane.add(mid SubPane4);
midPane.add(mid SubPane5);
midPane.add(mid SubPane6);
midPane.add(mid SubPane7);
midPane.add(mid SubPane8);
midPane.add(mid SubPane9);
midPane.add(mid SubPane10);
midPane.add(mid SubPane11);
midPane.add(mid SubPane12);
midPane.add(edi tButton);
midPane.add(sav eButton);
rightPane.add(n ew JScrollPane(out putArea));
mainPane.add(le ftPane);
mainPane.add(mi dPane);
mainPane.add(ri ghtPane);
setContentPane( mainPane);
setLocation(10, 10);
setSize(800,500 );
setVisible(true );

}
}
Mar 4 '08 #1
0 1228

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

Similar topics

2
1879
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 hope to add additional features eventualy. In the early days of the project, we had a graphic/web designer volunteering some time with us, but she has since gotten busy with other projects. We are desperate for someone to help us with the visual...
17
1974
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 tomorrow. I was on vacation when we went over how to read files, so basically my only resources are the book, the course notes, and the examples. Unfortunately for me, none of them are usefull at all, so pretty much i don't have a clue as to what i...
22
1563
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 server reported the following error when attempting to create or open the Web project located at the following URL:..... HTTP/1.1 500 Internal Server Error." People have said Frontpage Server Extensions (FPSE) have to be on that server; however,...
4
1873
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 XP-Pro (and therefore IIs 5.1) and have instannled .Net framework v1.1.4322. I canot create a new web project - I get the error
4
1238
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 Application project (with only the default blank page) and immediately tried to start the project - it does not work, showing me the following stupid error: Server Error in '/WebApplication1' Application...
1
6826
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 message: "Unable to install or run the application. The application requires that assembly EnvDTE Version 7.0.330.0 be installed in the Global Assembly Cache (GAC) first." When I now reference the assembly Envdte (Version 7.0.330.0) and include...
23
2562
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
1217
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 it to an arry of ints. I can get the first one to read in fine, but then it seems to ignore the rest. I suspect it involves the comma because when I replace them with spaces it works perfect. The issue is that I have to keep everything the way it...
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10379
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6882
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.