Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. public static void main(String[] args) throws Exception{
  2.  
  3.  
  4. String cont1=" ";
  5. String X;
  6. int x1,arr_count=1;
  7. String[] option = {"First Name","Last Name","Course"};
  8.  
  9. BufferedReader reader1=new BufferedReader(new InputStreamReader(System.in));
  10. do{
  11.  
  12. System.out.println("nWelcome! Please select a task: nA. View a record.nB. Add a record.nC. Edit a record.nD. Exit the program.");
  13. String option1 = reader1.readLine();
  14.  
  15. if("a".equals(option1)|| "A".equals(option1)){
  16. System.out.println("Please enter the Student ID for the record to view.");
  17. String a = reader1.readLine();
  18. x1 = Integer.parseInt(a);
  19. for(int y=0;y<3;y++){
  20. System.out.print(Records.getRecord(x1,y) + " ");
  21. }
  22. System.out.print("nSubjects and Grades: n");
  23. for(int y=3;y<6;y++){
  24. System.out.print(Records.getRecord(x1,y) + " (" + Records.getRecord(x1,y+3) + ")n");
  25. }
  26.  
  27. System.out.println("nReturn to Main Menu? (Y/N)");
  28. cont1= reader1.readLine();
  29. }
  30.  
  31. else if("b".equals(option1)||"B".equals(option1)){
  32. arr_count++;
  33. for (int y = 0; y<3;y++){
  34. System.out.println("Enter Value for "+ option [y]+":" );
  35. X = reader1.readLine();
  36. X = Records.getRecord(arr_count,y);
  37. }
  38.  
  39. System.out.println("nNew Student added:nID number: "+ arr_count);
  40. for(int y=0;y<3;y++){
  41. X = Records.getRecord(arr_count,y);
  42. System.out.print(X + " ");
  43. }
  44.  
  45. public class Records {
  46.  
  47. public static String getRecord(int recordID,int index1)throws Exception{
  48. //BufferedReader reader1=new BufferedReader(new InputStreamReader(System.in));
  49. String records[][] = new String [10][9];
  50. records[0][0] = "John"; records[0][3] = "English"; records[0][6] = "C";
  51. records[0][1] = "Smith"; records[0][4] = "Math"; records[0][7] = "B";
  52. records[0][2] = "BS IT"; records[0][5] = "Graphics"; records[0][8] = "A";
  53.  
  54. records[1][0] = "Juan"; records[1][3] = "Graphics"; records[1][6] = "B";
  55. records[1][1] = "Ponce"; records[1][4] = "Math"; records[1][7] = "B";
  56. records[1][2] = "BS ECE"; records[1][5] = "Robotics"; records[1][8] = "A";
  57.  
  58. /**records[2][0] = ""; records[2][3] = ""; records[2][6] = "";
  59. records[2][1] = ""; records[2][4] = ""; records[2][7] = "";
  60. records[2][2] = ""; records[2][5] = ""; records[2][8] = "";
  61.  
  62. records[3][0] = ""; records[3][3] = ""; records[3][6] = "";
  63. records[3][1] = ""; records[3][4] = ""; records[3][7] = "";
  64. records[3][2] = ""; records[3][5] = ""; records[3][8] = "";
  65.  
  66. records[4][0] = ""; records[4][3] = ""; records[4][6] = "";
  67. records[4][1] = ""; records[4][4] = ""; records[4][7] = "";
  68. records[4][2] = ""; records[4][5] = ""; records[4][8] = "";*/
  69.  
  70.  
  71.  
  72. return records[recordID][index1];
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement