Hi,
I have this really important project where in, I must perform the following tasks.
VIEW - view records that are present in the database using a "primary key"
ADD - add new records to the database
EDIT - a specific line in the said record within the database
Under edit, user should be able to choose what to edit: Student ID, Name, Course, Address and School.
DELETE - delete a record
Other requirements:
1. Database should NOT be a text file, I should ONLY use an array to store the data.
2. Can use, bufferedReader or JOptionPane, but preferably, I'm using JOptionPane.
3. For example, if I have 2 set of records:
Student ID: 1
Name: Mark Wall
Course: BSBA
Address: San Diego, California
School: UCLA
Student ID: 2
Name: Jim Raynor
Course: BSAS
Address: Los Angeles, California
School: UCLA
During the VIEW/I will input the Student ID that I am looking for. If i input 1. It should show this:
Student ID: 1
Name: Mark Wall
Course: BSBA
Address: San Diego, California
School: UCLA
If not existent, it will prompt to try again.
So far, here's what I've got:
import javax.swing.JOptionPane;
public class StudRecvoid
{
public void Info ()
{
// main switch dec start
int num = 0;
String str = "";
// main case 1 dec start
int numa = 0;
String stra = "";
// main case 1 dec end
// main case 2 dec start
int numb = 0;
String strb = "";
String strb1 = "";
String strb2 = "";
String strb3 = "";
String strb4 = "";
// main case 2 dec end
// main case 3 dec start
int numc = 0;
String strc = "";
// main case 3 dec end
// main case 4 dec end
int numd = 0;
String strd = "";
// main case 4 dec end
// main switch dec end
System.out.println("What do you want to do?");
System.out.println("1 -> View");
System.out.println("2 -> Add");
System.out.println("3 -> Edit");
System.out.println("4 -> Delete");
JOptionPane.showMessageDialog(null, "Please choose a number from 1 to 4");
str = JOptionPane.showInputDialog("Choose an action to take:");
num = Integer.parseInt(str);
switch (num) // main switch start
{
case 1: // main case 1
JOptionPane.showMessageDialog(null, "You have chosen to VIEW Student Records");
stra = JOptionPane.showInputDialog("Input the entry's Student ID:");
numa = Integer.parseInt(stra);
switch (numa) // start of Subcases for main case 1
{
case 1: // subcase 1.1
JOptionPane.showMessageDialog(null, "Record 1");
break;
case 2: // subcase 1.2
JOptionPane.showMessageDialog(null, "Record 2");
break;
case 3: // subcase 1.3
JOptionPane.showMessageDialog(null, "Record 3");
break;
case 4: // subcase 1.4
JOptionPane.showMessageDialog(null, "Record 4");
break;
default: // sub default 1
JOptionPane.showMessageDialog(null, "RECORD does not exist, please run the program again.");
break;
} //end of subcases for main case 1
break;
case 2: // main case 2
JOptionPane.showMessageDialog(null, "You have chosen to ADD a new Student Record");
strb = JOptionPane.showInputDialog("Input Student ID:");
numb = Integer.parseInt(strb);
strb1 = JOptionPane.showInputDialog("Input Full Name:");
strb2 = JOptionPane.showInputDialog("Input Course:");
strb3 = JOptionPane.showInputDialog("Input Address:");
strb4 = JOptionPane.showInputDialog("Input School:");
JOptionPane.showMessageDialog(null, "Record succesfuly added!");
int arrayinfonum[]={numb};
String arrayinfostr[]={strb1, strb2, strb3, strb4};
System.out.println ();
System.out.println ("Student ID: " + numb);
System.out.println ("Name: " +strb1);
System.out.println ("Course: " +strb2);
System.out.println ("Address: " +strb3);
System.out.println ("School: " +strb4);
break;
case 3: // main case 3
System.out.println("Edit");
break;
case 4: // main case 4
System.out.println("Delete");
break;
default: // main default
System.out.println("Please choose from 1 to 4 only");
break;
} // main switch end
}
}
I really need help on this. Because this will basically decide if I pass or fail for this semester in my major. Thank you very much!!!