The Artima Developer Community
Sponsored Link

Java Answers Forum
guys take a look.. i need your help...plz..plz..

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
emz dee

Posts: 1
Nickname: fatima
Registered: Mar, 2009

guys take a look.. i need your help...plz..plz.. Posted: Mar 18, 2009 10:48 PM
Reply to this message Reply
Advertisement
anyone can make a program which will...
ADD
DELETE
UPDATE AND
SEARCH DATA/INFORMATION..
ohh java source code i mean
using graphical user interface..
ive got an example here "student profile"
its not complete yet mmm..



package studentproject;

/**
*
* @author Cisco_lab
*/


import javax.swing.JOptionPane;

public class StudentProfile2{

public static void main(String[] args) {

String output = "", name, up;
double m, e,s;
Student [] student = new Student[5];

int i=0;
int u=0,f=0;

String choice, again;
char c,ans;


do{
choice = JOptionPane.showInputDialog(" MENU " + "\n" +
"[a] ADD a RECORD " + "\n" +
"[d] DISPLAY RECORDs" +"\n" +
"[e] DELETE a RECORD"+"\n" +
"[p] UPDATE a RECORD"+"\n" +
"[s] SEARCH a RECORD"+"\n" +
"Enter choice: ");

choice = choice.trim();
c = choice.charAt(0);

switch(c){
case 'a': student = new Student();
name=JOptionPane.showInputDialog(" Enter name: ");
student.setName(name);

String mg = JOptionPane.showInputDialog("Name: "+name + "\nEnter Math Grade ");
m = Double.parseDouble(mg);
student.setmGrade(m);
String eg = JOptionPane.showInputDialog("Name: "+name + "\nEnter English Grade ");
e = Double.parseDouble(eg);
student.seteGrade(e);
String sg = JOptionPane.showInputDialog("Name: "+name + "\nEnter Science Grade ");
s = Double.parseDouble(sg);
student.setsGrade(s);

i++;

break;


case 'd': if (i==0)
JOptionPane.showMessageDialog(null,"NO RECORDS yet!!!");

else{

output = "Name " + "Math " + "English " + "Science " + " Average " + "\n";

for(int x=0; x<i; x++){
output = output + "\n" +
student[x].getName()+" "+ student[x].getmGrade()+" "+ student[x].geteGrade()+" "+student[x].getsGrade()+ " "+ student[x].getAverage();
}
JOptionPane.showMessageDialog(null,output);
}

break;

case 's':

up = JOptionPane.showInputDialog("Enter name to search: ");
for(int x=0; x<i; x++){
if ((student[x].getName().equalsIgnoreCase(up))){
u=x;
f=1;
JOptionPane.showMessageDialog(null,"FILE FOUND!!!");
break;
}
}

if(f==1){

output = "Name " + "Math " + "English " + "Science " + " Average " + "\n";
output = output + "\n" +
student.getName()+" "+ student.getmGrade()+" "+ student.geteGrade()+" "+student.getsGrade()+ " "+ student.getAverage();

JOptionPane.showMessageDialog(null,output);
}
else
JOptionPane.showMessageDialog(null,"NAME DOES EXIST!!!");

break;

case 'p':

up = JOptionPane.showInputDialog("Enter name to update: ");
for(int x=0; x<i; x++){
if ((student[x].getName().equalsIgnoreCase(up))){
u=x;
f=1;
JOptionPane.showMessageDialog(null,"FILE FOUND!!!");
break;
}
}
if(f==1){

name=JOptionPane.showInputDialog(" Enter name: ");
student.setName(name);

mg = JOptionPane.showInputDialog("Name: "+name + "\nEnter Math Grade ");
m = Double.parseDouble(mg);
student.setmGrade(m);
eg = JOptionPane.showInputDialog("Name: "+name + "\nEnter English Grade ");
e = Double.parseDouble(eg);
student.seteGrade(e);
sg = JOptionPane.showInputDialog("Name: "+name + "\nEnter Science Grade ");
s = Double.parseDouble(sg);
student.setsGrade(s);
JOptionPane.showMessageDialog(null,"FILE SUCCESSFULLY UPDATED!!!");
}
else
JOptionPane.showMessageDialog(null,"NAME DOES EXIST!!!");





break;




case 'e':
up = JOptionPane.showInputDialog("Enter name to delete: ");
for(int x=0; x<i; x++){
if ((student[x].getName().equalsIgnoreCase(up))){
u=x;
f=1;
JOptionPane.showMessageDialog(null,"FILE FOUND!!!");
break;
}
}
if(f==1){

student=null;

for(m=u; m<i; m++){
student = student[u+1];
}

JOptionPane.showMessageDialog(null,"FILE SUCCESSFULLY DELETED!!!");
i--;
}
else
JOptionPane.showMessageDialog(null,"NAME DOES EXIST!!!");

break;

}


again = JOptionPane.showInputDialog("Another transaction? [y/n]");
again=again.trim();
ans=again.charAt(0);
}while(ans=='y'||ans=='Y');

}

}



package directoryproject;

/**
*
* @author Cisco_lab
*/
public class Student {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

StudentGUI app =new StudentGUI();
app.setVisible(true);


}

}

Topic: I need help! Previous Topic   Next Topic Topic: data structures in java stacks and queue plz help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use