Guest User

Untitled

a guest
Nov 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import java.util.*;
  2. public class Student
  3. {
  4. //Private Variables (Available throughout Class)
  5. private String firstName;
  6. private String lastName;
  7. private int grade;
  8. private double gpa;
  9. private int studentID;
  10. Random rn = new Random();
  11. public Student(String lName, String fName, int classGrade)
  12.  
  13. //Parameter
  14. Constructor
  15. {
  16. lastName= lName;
  17. firstName=fName;
  18. grade=classGrade;
  19. gpa=0.0;
  20. studentID=rn.nextInt(201850)+201806;
  21. }
  22.  
  23. public Student() //Default Constructor
  24. {
  25. firstName=null;
  26. lastName=null;
  27. grade = 9;
  28. gpa = 0.00;
  29. studentID=rn.nextInt(201850)+201806;
  30. }
  31.  
  32. public void printStudentInfo()
  33. {
  34. System.out.println("Student Information");
  35. System.out.println("Name : " +firstName+" "+lastName);
  36. System.out.println("Grade : " +grade);
  37. System.out.println("Gpa : " +gpa);
  38. System.out.println("Student ID : " +studentID);
  39. System.out.println();
  40. }
  41. public void setGpa(double newGpa)
  42. {
  43. gpa=newGpa;
  44. }
  45. public void setName(String newlastName, String newfirstName)
  46. {
  47. firstName=newfirstName;
  48. lastName=newlastName;
  49. }
  50. public void setGrade(int newGrade)
  51. {
  52. grade=newGrade;
  53. }
  54.  
  55. // Challenge Methods ///////////////////////
  56. public void printGrad()
  57. {
  58. System.out.println("Here's the graduation status :");
  59. if(grade==9)
  60. System.out.println(firstName+ " " +lastName+ " is expected to graduate in
  61. 4 years.)");
  62. if(grade==10)
  63. System.out.println(firstName+ " " +lastName+ " is expected to graduate in
  64. 3 years.");
  65. if(grade==11)
  66. System.out.println(firstName+ " " +lastName+ " is expected to graduate in
  67. 2 years.");
  68. if(grade==12)
  69. System.out.println(firstName+ " " +lastName+ " is expected to graduate
  70. this year.");
  71. }
  72.  
  73. public void compareToStudent()
  74. {
  75. //NEED HELP HERE.
  76. }
  77. }
Add Comment
Please, Sign In to add comment