Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package egzaminoceny;
- //class Oceny
- //{
- // private float[][] oceny = null;
- //
- // public Oceny( int liczbaStudentow, int liczbaPrzedmiotow )
- // {
- // oceny = new float[liczbaStudentow][liczbaPrzedmiotow];
- // for( int nrStud = 0; nrStud < oceny.length; ++nrStud )
- // for( int nrPrzed = 0; nrPrzed < oceny[ nrStud ].length; ++nrPrzed )
- // oceny[ nrStud ][ nrPrzed ] = -1;
- // }
- // public void wpiszOcene(int student, int przedmiot, float ocena )
- // {
- // if( student < 0 || student >= oceny.length )
- // return;
- // if( przedmiot < 0 || przedmiot >= oceny[ student ].length )
- // return;
- // if( ocena >= 2 && ocena <= 5 )
- // oceny[ student ][ przedmiot ] = ocena;
- // }
- // public float obliczSredna( int student )
- // {
- // if( student < 0 || student >= oceny[ student ].length )
- // return 0;
- //
- // float suma = 0;
- // int ileOcenWystawionych = 0;
- // for( int nrPrzed = 0; nrPrzed < oceny[ student ].length; ++nrPrzed )
- // if( oceny[ student ][ nrPrzed ] != -1 )
- // {
- // suma += oceny[ student ][ nrPrzed ];
- // ileOcenWystawionych++;
- // }
- //
- // if( ileOcenWystawionych > 0 )
- // return suma / ileOcenWystawionych;
- // else
- // return 0;
- // }
- //
- // public boolean zaliczonySemestr(int student)
- // {
- // float srednia=0;
- // srednia=obliczSredna(student);
- //
- // for( int nrStud = 0; nrStud < oceny.length; ++nrStud )
- // for( int nrPrzed = 0; nrPrzed < oceny[ nrStud ].length; ++nrPrzed )
- // if( oceny[ student ][ nrPrzed ] == -1 )
- // return false;
- //
- // if(srednia<3.0)
- // return false;
- //
- // else
- // return true;
- //
- // }
- //
- // void zmienOcene (int student, int przedmiot, float ocena)
- // {
- // if (student <0 || student >= oceny.length)
- // return;
- // if (przedmiot<0 || przedmiot>=oceny[student].length)
- // return;
- // if( !(ocena >= 2 && ocena <= 5) )
- // return;
- //
- // float srednia=0;
- //
- // if(oceny[student][przedmiot]==-1)
- // srednia = ocena/2;
- //
- // srednia = (oceny[student][przedmiot] + ocena)/2;
- // oceny[ student ][ przedmiot ] = srednia;
- //
- // }
- //
- // void pisz()
- // {
- //
- // }
- //}
- public class EgzaminOceny
- {
- public static void main(String[] args)
- {
- // Oceny dzienniczek = new Oceny( 5, 3 );
- // dzienniczek.wpiszOcene( 0, 0, 5.0f );
- // float srednia = dzienniczek.obliczSredna( 1 );
- //
- // System.out.println( "Średnia: " + srednia );
- //
- // dzienniczek.zaliczonySemestr(2);
- int tab[][] =
- {
- {-1,10,123},
- {8,30,13,},
- {0,-10,153}
- };
- for (int i=0; i<tab.length;i++)
- {
- String listaOcen = "";
- float srednia = 0;
- float suma = 0;
- for (int j=0; j>tab[i].length;j++)
- {
- if(tab[i][j] != -1)
- {
- listaOcen = listaOcen + " " + tab[i][j] + " ";
- suma += tab[i][j];
- }
- System.out.println("Student " + i +" Oceny" + listaOcen + " średnia " + suma/tab[i].length);
- }
- }
- // for (int i=0;i<tab.length;i++)
- // for(int j = 0; j<tab[i].length;j++)
- // System.out.print(tab[i][j] + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement