TomorrowIsAMystery
Member
- Aug 8, 2014
- 43
- 3
Hey, so I've decided to release a project I completed which was a school database system. It allows you to search a student using binary search, count average marks, find out last names, first names, etc of any excel document. I've included two excel documents, one has 1000 fields filled out with last name, first name, student mark, course average etc. It also lets you update and save fields, as a new excel document or override the existing one.
The main purpose is for java student to read the code and detailed comments and to mess around with it and add their own flare. Also if you would like, make it an exceutable and run it in cmd or even make an applet out of it. Go nuts, even aspiring coders should take a read for shits and giggles on notepad.
anyways heres the link
and heres an example of the code:
The main purpose is for java student to read the code and detailed comments and to mess around with it and add their own flare. Also if you would like, make it an exceutable and run it in cmd or even make an applet out of it. Go nuts, even aspiring coders should take a read for shits and giggles on notepad.
anyways heres the link
You must be registered for see links
and heres an example of the code:
Code:
public static boolean menu() throws IOException {
//THIS MENU PROMPTS ALLOWS YOU TO WORK WITH THE FILE AND READ AND WRITE SPECIFIC DATA
Scanner userInput = new Scanner(System.in); //SCANNER FOR THE USERS INPUT
do { //DO LOOP FOR AN EXECUTE FOR A GIVEN NUMBER OF TIMES (NUMBER OF TIMES DECLARED BY WHILE SOMETHING)
choice = "";
System.out.println("============================================="); //MENU OPTIONS (THEY ARE LOOPED TO BE DONE INDEFINATLY)
System.out.println("Type R To Read Another File");
System.out.println("Type L To Print all File Records");
System.out.println("Type AA To Print The Average Of All The Marks");
System.out.println("Type AC To Print Marks For a Specific Course");
System.out.println("Type NM To Change a Students Mark");
System.out.println("Type X To Exit The Program");
choice = userInput.nextLine(); //READS THE USERS CHOICE FOR WHAT THEY WANT TO DO WITH THE FILE
if (choice.equalsIgnoreCase("L")) { //IF THE CHOICE WAS THE LETTER L THEN RUN METHOD BELOW IT (SO IT CALLS THAT METHOD AND THAT METHOD IS RUN)
printList();
} else if (choice.equalsIgnoreCase("R")) {
fileChange();
} else if (choice.equalsIgnoreCase("AA")) {
average();
} else if (choice.equalsIgnoreCase("X")) {
exit();
} else if (choice.equalsIgnoreCase("AC")) {
courseAverage();
} else if (choice.equalsIgnoreCase("NM")) {
newMark();
} else if (choice.equalsIgnoreCase("RM")) {
} else {
System.err.println("Unknown Key Try Again..."); //IF THE USER INPUT WAS NONE OF THESE CHOICES THEN THROW THEM A NOTICE
}
} while (!choice.equalsIgnoreCase("x")); //DO WHILE THE CHOICE IS NOT X WHICH EXITS THE PROGRAM
return false;
}
public static void fileChange() throws IOException { //FILE CHANGE METHOD READS ANOTHER FILE THAT IS ASKED BY THE USER
readFile(user); //CALLS THE READFILE METHOD IN ORDER TO READ THAT FILE AND RUN IT PROPERLY AND IT READS THE FILE PROMPTED BY THE USER
}
public static void printList() { //PRINTS OUT ALL THE FIELDS OF DATA FOR EVERY STUDENT
for (int i = 0; i < numstu; i++) { //FROM 0 TO THE END OF THE FIELDS IN THE FILE
System.out.println(stu[i].toString()); //PRINT OUT THE REQUESTED CLASS
}
}
public static void average() { //AN AVERAGE CALCULATOR FOR THE ENTIRE STUDENT BODY
for (int i = 0; i < numstu; i++) { //FOR LOOP TO READ EVERY STUDENT RECORD
average += stu[i].mark; // keep adding to average //FOR EVERY RECORD ADD THE MARK OF THAT RECORD TO THE VARIABLE AVERAGE
}
// dividision by zero protection
if (choice.equalsIgnoreCase("AA") && numstu > 0) {
average = average / numstu; // compute the average. Always use the size in terms of a variable whenever possible.
System.out.println(average); // as noted below, if this is an integer value, < #of students computations will eval to 0.
} else if (!choice.equalsIgnoreCase("AA") && numstu < 0) { //IF THE MARK IS LESS THEN 0 THEN THERE MUST BE A PROBLEM
System.out.println("Oops! No Marks To Calculate!"); //PRINT OUT A NOTICE OF THE ISSUE
}
}
//THIS METHOD CALCULATES THE AVERAGE FOR A SPECIFIED COURSE
public static void courseAverage() {
System.out.println("Please Type In The Class Course Code"); //PROMPTS USER TO SELECT A COURSE TO CALCULATE
int markAdder = 0; //COUNTER FOR THE MARKS (IT ADDS UP)
int counter = 0; //COUNTER FOR THE AMOUNT OF STUDENTS IN THAT COURSE
int finalAverage; //FINALAVERAGE CALCULATOR
String choicer; //USERINPUT CHOICE
Scanner reader = new Scanner(System.in); //SCANNER FOR WHAT THE USER TYPES
choicer = reader.nextLine(); //WHATEVER THE USER TYPED IS STORED IN THE VARIABLE CHOICER
for (int i = 0; i < numstu; i++) { //FOR LOOP EVERY SINGLE FIELD IN THE FILE
if (stu[i].courseCode.equalsIgnoreCase(choicer)) { //IF THE COURSECODE EQUALS TO WHAT THE USER TYPES THEN...
markAdder += stu[i].mark; //GO TO THAT STUDENTS MARK AND ADD IT TO THE MARKADDER VARIABLE
counter++; //THIS COUNTS THE AMOUNT OF STUDENTS IN THAT COURSE FOR THE FINAL CALCULATION
}
}