Advertisement
Giroe

Untitled

Feb 26th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Student {
  4. public
  5. String nume;
  6. int note1;
  7. int note2;
  8. int note3;
  9. float medie=(note1+note2+note3)/3;
  10. String grupa;
  11.  
  12.  
  13.  
  14. public void setNume(String nume) {
  15. this.nume = nume;
  16. }
  17.  
  18. public String getNume() {
  19. return nume;
  20. }
  21.  
  22. // public void setNote(int note) {
  23. // this.note = note;
  24. // }
  25.  
  26.  
  27. public void setNote1(int note1) {
  28. this.note1 = note1;
  29. }
  30.  
  31. public void setNote2(int note2) {
  32. this.note2 = note2;
  33. }
  34.  
  35. public void setNota3(int nota3) {
  36. this.note3 = nota3;
  37. }
  38.  
  39. public int getNote1() {
  40. return note1;
  41. }
  42.  
  43. public int getNote2() {
  44. return note2;
  45. }
  46.  
  47. public int getNota3() {
  48. return note3;
  49. }
  50.  
  51. public void setGrupa(String grupa) {
  52. this.grupa = grupa;
  53. }
  54.  
  55. public String getGrupa() {
  56. return grupa;
  57. }
  58.  
  59. public void setMedie(float medie) {
  60. this.medie = medie;
  61. }
  62.  
  63. public float getMedie() {
  64. return medie;
  65. }
  66. // Scanner sc=new Scanner(System.in);
  67. //String nume=sc.nextLine();
  68. // int note=Integer.parseInt(sc.nextLine());
  69. // String grupa=sc.nextLine();
  70. //float mediee=(note1 +note2 + note3)/3;
  71.  
  72.  
  73.  
  74. public Student(String nume,String grupa,int nota1,int nota2,int nota3,float medie){
  75. //
  76. this.nume=nume;
  77. this.note1=nota1;
  78. this.note2=nota2;
  79. this.note3=nota3;
  80. this.grupa=grupa;
  81. this.medie=medie;
  82.  
  83. }
  84. void Afisare(){
  85. float medie;
  86. // medie= (this.note1 +this.note2 + this.note3)/3;
  87. System.out.println(this.nume+" " + this.grupa + " " + this.note1 + " " + this.note2 +" " + this.note3 + " " + "media notelor este: " + this.medie);
  88.  
  89. }
  90. }
  91. //Main
  92. import java.util.Scanner;
  93.  
  94. class Main {
  95. public static void main(String[] args) {
  96.  
  97.  
  98. Scanner scanner = new Scanner(System.in);
  99. // int n=Integer.parseInt(sc.nextLine());
  100.  
  101. //Student s1 = new Student("Alex","221/2",5,4,6 ,5);
  102. //Student s2 = new Student("Alexandra","223/2",9,5 ,6,6);
  103. //Student s3 = new Student("Cristina","224/2",9,8 , 9,8);
  104. //Student s4 = new Student("Larisa","222/2",9,6 , 9,8);
  105.  
  106. //s1.Afisare();
  107. //s2.Afisare();
  108. //s3.Afisare();
  109. //s4.Afisare();
  110.  
  111. System.out.print("n=");
  112. int n= Integer.parseInt(scanner.nextLine());
  113. Student []student = new Student[n];
  114. for (int i=1; i<=n;i++)
  115. {
  116.  
  117. student[i].setNume(scanner.nextLine());
  118.  
  119. System.out.print("nume student : ");
  120.  
  121.  
  122.  
  123. System.out.println(student[i].getNume());
  124. }
  125.  
  126.  
  127. System.out.println();
  128. System.out.println(".......................................");
  129.  
  130.  
  131.  
  132. }
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement