All pastes #383495 Raw Edit

MarksManager2

public java v1 · immutable
·published 2007-03-06 12:23 UTC
rendered paste body
/** * @(#)markmanager.java * * * @author  mike C * @version 1.00 2007/2/26 */ import java.io.*;import java.util.Arrays;import java.util.ArrayList;public class marksManager {static int selectedMode=0;static ArrayList<student> studentTracker = new ArrayList<student>();/* selectedMode Mode Reference-0.On Main Menu1.Create New Student2.Edit Student information3.Overview4.Exit Program :(*/	private static void mainMenu () {		System.out.println("\n Manage Marks and Stuff- \n 1.New Student \n 2.Edit Student \n 3.Overview \n 4.Exit Program");}public static void newStudent () throws IOException {	String nameFirst, nameLast;	int numberStudent=0;	boolean satisfaction=false;	boolean bit8Correction=false;	String temp2="";	student tempReader;	BufferedReader getIN = new BufferedReader (new InputStreamReader (System.in));	while (satisfaction == false){		for (int i1=0;;i1++){//Input student information.				System.out.println("Please enter the student's last name.");			nameLast = getIN.readLine();			System.out.println("Please enter the student's first name.");			nameFirst = getIN.readLine();			while (bit8Correction==false){				// Loop to make sure that number entered is 8 digits.				System.out.println("Please enter the student's number.");				temp2 = getIN.readLine();								numberStudent =Integer.parseInt(temp2);								if (temp2.length()==8){					bit8Correction=true;				}							}//Check if the data is correct.			System.out.println("Student Information is as follows: "+nameLast+", "+nameFirst+"\n Number: "+numberStudent);			System.out.println("Is this correct?");			temp2 = getIN.readLine();						if (temp2.indexOf("y")>=0 || temp2.indexOf("Y")>=0){				// If satisfied with input create a new student (create a temp array, then make the main equal to the temp)				satisfaction = true;									studentTracker.add(studentTracker.size(),new student(nameLast,nameFirst,numberStudent));			break;			}			}				}	System.out.println("Back to Main Menu."); }public static void editStudent () throws IOException {	// Show class then take either a name or a student number	selectedMode=choice(selectedMode, studentTracker.size());}public static void overView () throws IOException {	// Show Individual Marks, or Show Class Marks	System.out.println("There are currently "+studentTracker.size()+" students being accounted for.");	for (int i=0; studentTracker.size() >i ; i++){		studentTracker.get(i).displayInfo();		}	}public static void deleteStudent () throws IOException {	}public static int choice (int currentSel, int upperBounds) throws IOException  {BufferedReader getIN = new BufferedReader (new InputStreamReader (System.in));	for (int inf=0;;inf++){ 		for (int inf2=0;;inf2++){ 			String temp = getIN.readLine();		int i = Integer.parseInt(temp);			if (i <= upperBounds & i >= 1){				System.out.println("Acceptable");				return i;			}else{				System.out.println("Sorry, that's not a valid option.");				break;						}		}	}	}public static void main(String[] args) throws IOException {    	    	boolean letMeOut = false;    	while (letMeOut == false){    	    	  	   	    		mainMenu();     		selectedMode=choice(selectedMode, 4);    		    		switch(selectedMode){				case(1):					newStudent ();					break;							case(2):					System.out.println("There are "+studentTracker.size()+" unique students, being tracked."); 					editStudent();					break;				case(3):					overView();					break;				case(4):					letMeOut=true;					default:									//mainMenu(); 				System.out.println("Thanks for using this useless program, all your hard work in data input is now being deleted. \n Have a nice day. :)");    		}    	}    	    }        }