Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1.  
  2.  
  3. import java.util.*;
  4. import java.io.*;
  5. import filestuff.*;
  6.  
  7. public class StudentStuff
  8. {
  9. public static void studentInfo(String[][]g,String studentName)
  10. {
  11. Scanner in=new Scanner(System.in);
  12. boolean c=false;
  13. for(int i=0;i<g.length;i++)
  14. {
  15. if(g[i][0].equals(studentName))
  16. {
  17. System.out.println("**Class number:"+ (g[i][1])+"\n **Class name:"+(g[i][2])+"\n **Final grade:"+(g[i][3]));
  18. c=true;
  19. }
  20. }
  21. if(c==false)
  22. {
  23. System.out.println("No student named "+studentName+" found.");
  24. }
  25. }
  26.  
  27. public static void main(String[]args)
  28. {
  29. String[][]g=FileHandle.genFile();
  30. Scanner in=new Scanner(System.in);
  31. String choice="";
  32. choice=FileHandle.getUserInput("Type 1 to get a student's info:\n Type 2 to type in a class name to output file with student list:\n Type 3 to enter a class name/number to see average grade:\n Type 4 to quit.\n");
  33. int numchoice=Integer.parseInt(choice);
  34.  
  35. if(numchoice==1)
  36. {
  37. String studentName=FileHandle.getUserInput("Enter name of student:\n");
  38. studentInfo(g,studentName);
  39.  
  40. }
  41. else if(numchoice==2)
  42. {
  43. String classchoice=FileHandle.getUserInput("Type class you wish to view list of:");
  44. int rows=g.length;
  45.  
  46. for(int i=0;i<rows;i++)
  47. {
  48.  
  49. if((g[i][2]).equals(classchoice))
  50. {
  51. System.out.println(g[i][0]);
  52. }
  53. }
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement