Guest User

Untitled

a guest
Oct 23rd, 2019
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package User;
  3.  
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class Student extends Person {
  8. public Student ()
  9. {
  10. super();
  11. sId = 0;
  12. major = "TBA";
  13. cgpa = 0.0f;
  14. }
  15.  
  16. public Student(int sId, float cgpa, String major) {
  17. this.sId = sId;
  18. this.cgpa = cgpa;
  19. this.major = major;
  20. }
  21. int sId; float cgpa; String major;
  22. void setStudentInfo()
  23. {
  24. Scanner s = new Scanner(System.in);
  25. System.out.println("Enter id: ");
  26. sId = s.nextInt();
  27. setPersonInfo();
  28. System.out.println("Enter cgpa: ");
  29. cgpa = s.nextFloat();
  30. System.out.println("enter major: ");
  31. major = s.nextLine();
  32. }
  33. public void showStudentInfo()
  34. {
  35. System.out.println(sId+"ID =");
  36. showPersonInfo();
  37. System.out.println("cgpa"+cgpa);
  38. //s.nextlLine();
  39. System.out.println("major = "+major);
  40. }
  41. }
  42.  
  43.  
  44. //////////////
  45.  
  46. package User;
  47.  
  48. import java.util.Scanner;
  49.  
  50.  
  51. public class Person {
  52.  
  53. public Person(String name, String dob, String bg) {
  54. this.name = name;
  55. this.dob = dob;
  56. this.bg = bg;
  57. }
  58.  
  59. public String getName() {
  60. return name;
  61. }
  62.  
  63. public String getDob() {
  64. return dob;
  65. }
  66.  
  67. public String getBg() {
  68. return bg;
  69. }
  70.  
  71. public void setName(String name) {
  72. this.name = name;
  73. }
  74.  
  75. public void setDob(String dob) {
  76. this.dob = dob;
  77. }
  78.  
  79. public void setBg(String bg) {
  80. this.bg = bg;
  81. }
  82. //private String name, dob, bg;
  83. protected String name, dob, bg;
  84. public Person()
  85. {
  86. name=dob=bg="TBA";
  87. }
  88.  
  89. public void setPersonInfo()
  90. {
  91. Scanner s= new Scanner(System.in);
  92. System.out.println("Enter Name : ");
  93. name = s.nextLine();
  94. System.out.println("Enter dob : ");
  95. dob = s.nextLine();
  96. bg = s.nextLine();
  97. }
  98.  
  99. public void showPersonInfo()
  100. {
  101. System.out.println("name =" +name+"bob= "+dob+"bg +"+bg);
  102.  
  103. }
  104. }
  105.  
  106.  
  107. //////////////////
  108.  
  109. package User;
  110.  
  111. import java.util.Scanner;
  112.  
  113.  
  114. public class Person {
  115.  
  116. public Person(String name, String dob, String bg) {
  117. this.name = name;
  118. this.dob = dob;
  119. this.bg = bg;
  120. }
  121.  
  122. public String getName() {
  123. return name;
  124. }
  125.  
  126. public String getDob() {
  127. return dob;
  128. }
  129.  
  130. public String getBg() {
  131. return bg;
  132. }
  133.  
  134. public void setName(String name) {
  135. this.name = name;
  136. }
  137.  
  138. public void setDob(String dob) {
  139. this.dob = dob;
  140. }
  141.  
  142. public void setBg(String bg) {
  143. this.bg = bg;
  144. }
  145. //private String name, dob, bg;
  146. protected String name, dob, bg;
  147. public Person()
  148. {
  149. name=dob=bg="TBA";
  150. }
  151.  
  152. public void setPersonInfo()
  153. {
  154. Scanner s= new Scanner(System.in);
  155. System.out.println("Enter Name : ");
  156. name = s.nextLine();
  157. System.out.println("Enter dob : ");
  158. dob = s.nextLine();
  159. bg = s.nextLine();
  160. }
  161.  
  162. public void showPersonInfo()
  163. {
  164. System.out.println("name =" +name+"bob= "+dob+"bg +"+bg);
  165.  
  166. }
  167. }
RAW Paste Data