Advertisement
ALENTL

Student.java

Nov 29th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. package project0;
  2.  
  3. import java.io.DataInputStream;
  4.  
  5. import javax.sound.midi.VoiceStatus;
  6.  
  7. class Student
  8. {
  9. private int rollno;
  10. private String name;
  11. DataInputStream dis = new DataInputStream(System.in);
  12. public void getrollno()
  13. {
  14. try
  15. {
  16. System.out.print("Enter roll no");
  17. rollno = Integer.parseInt(dis.readLine());
  18. System.out.print("Enter name");
  19. name = dis.readLine();
  20. }
  21.  
  22. catch(Exception) {}
  23. }
  24. void putrollno{}
  25. {
  26. System.out.print("Roll No ="+rollno);
  27. System.out.print("Name = "+name);
  28. }
  29. }
  30.  
  31. class Marks extends Student
  32. {
  33. protected int m1,m2,m3;
  34. void getmarks{}
  35. {
  36. try
  37. {
  38. System.out.print("Enter marks:");
  39. m1 = Integer.parseInt(dis.readLine());
  40. m2 = Integer.parseInt(dis.readLine());
  41. m3 = Integer.parseInt(dis.readLine());
  42. }
  43.  
  44. catch(Exception e) {}
  45. }
  46.  
  47. void putmarks{}
  48. {
  49. System.out.print("m1 = "+m1);
  50. System.out.print("m2 = "+m2);
  51. System.out.print("m3 = "+m3);
  52. }
  53. }
  54.  
  55. class Result extends Marks
  56. {
  57. private float total;
  58. void compute_display()
  59.  
  60. {
  61. total = m1 + m2 + m3;
  62. System.out.print("Total Marks = "+total);
  63. }
  64. }
  65.  
  66. class Multilevel
  67. {
  68. public static void public static void main(String[] args) {
  69. Result r = new Result();
  70. r.getrollno();
  71. r.getmarks();
  72. r.putrollno();
  73. r.putmarks();
  74. r.compute_display();
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement