Advertisement
Varasku

Student (dokoncz)

Jan 3rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. package sztudentakarysiu;
  2.  
  3. public class SztudentakaRysiu {
  4.  
  5.  
  6. public static void main(String[] args) {
  7. Student s1 = new Student("Krzysztof", "Bączek", 4);
  8. System.out.println("Koniec sesji = "+pierwszy.czyKoniecSesji());
  9. System.out.println("Zdane = "+pierwszy.czyZdane());
  10. System.out.println("Stypendium = "+pierwszy.czyStypendium());
  11. pierwszy.dodajOcene(5);
  12. pierwszy.dodajOcene(5);
  13. pierwszy.dodajOcene(4);
  14. pierwszy.dodajOcene(5);
  15. pierwszy.dodajOcene(3);
  16. System.out.println("Koniec sesji = "+pierwszy.czyKoniecSesji());
  17. System.out.println("Zdane = "+pierwszy.czyZdane());
  18. System.out.println("Stypendium = "+pierwszy.czyStypendium());
  19.  
  20. }
  21.  
  22. }
  23.  
  24. class Student{
  25.  
  26. public Student (String imie,string nazwisko ){
  27. oceny = new double[liczbaegzaminow];
  28. this.imie = imie;
  29. this.nazwisko = nazwisko;
  30. }
  31. public void wpiszOceny(double liczba){
  32. int poz = 0;
  33. while (oceny[poz] !=0) poz++;
  34. oceny[poz]=ocena;
  35. zaOstatnim = (zaOstatnim + 1);
  36.  
  37.  
  38.  
  39.  
  40. }
  41. public double wypiszOceny(){
  42. double liczba = dane[pierwszy];
  43. pierwszy = (pierwszy + 1);
  44. return liczba;
  45. }
  46. public boolean czyKoniecSesji(){
  47. for (int i = 0; i< oceny.length; i++)
  48. if(oceny[i] == 0) return false;
  49. return true;
  50.  
  51.  
  52. }
  53. public boolean czyZdane(){
  54. return czyKoniecSesji() && (srednia() >=3);
  55.  
  56. }
  57.  
  58. public boolean czyStypendium(){
  59. return czyKoniecSesji() && (srednia() > 4.5);
  60.  
  61. }
  62. private double srednia[]{
  63. double suma = 0;
  64. for(int i = 0; i <oceny.length; i++)
  65. suma+=oceny[i];
  66. return suma/oceny.length;
  67.  
  68. }
  69.  
  70. int liczbaegzaminow;
  71. double oceny[], dane[];
  72. int stopnie, pierwszy,liczba, zaOstatnim, ocena;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement