import java.util.Scanner ;
class Ex1 {
private float [ ] [ ] notes = new float [ 3 ] [ 4 ] ;
private float srednia1, srednia2, srednia3;
float result;
Scanner sc
= new Scanner
( System .
in ) ;
private void PobierzImieOdUsera( ) {
System .
out .
print ( "Podaj imię ucznia: " ) ; name = sc.next ( ) ;
}
private void PobierzPrzedmiotyIocene( ) {
for ( int i = 0 ; i < subjects.length ; i++ ) {
System .
out .
print ( "Podaj nazwy przedmiotów, których uczy się " + name
+ ": \n " ) ; subjects[ i] = sc.next ( ) ;
for ( int j = 0 ; j < subjects[ i] .length ( ) ; j++ ) {
System .
out .
print ( "Podaj ocenę dla przedmiotu " + subjects
[ i
] + ": \n " ) ; notes[ i] [ j] = sc.nextFloat ( ) ;
}
}
}
private void SrednieOcen( ) {
srednia1= ( notes[ 0 ] [ 0 ] + notes[ 0 ] [ 1 ] + notes[ 0 ] [ 2 ] ) / 3 ;
srednia2= ( notes[ 1 ] [ 0 ] + notes[ 1 ] [ 1 ] + notes[ 1 ] [ 2 ] ) / 3 ;
srednia3= ( notes[ 2 ] [ 0 ] + notes[ 2 ] [ 1 ] + notes[ 2 ] [ 2 ] ) / 3 ;
System .
out .
print ( "Srednia " + subjects
[ 0 ] + ": " + srednia1
+ " \n " ) ; System .
out .
print ( "Srednia " + subjects
[ 1 ] + ": " + srednia2
+ " \n " ) ; System .
out .
print ( "Srednia " + subjects
[ 2 ] + ": " + srednia3
+ " \n " ) ;
}
public static void main
( String [ ] args
) { Ex1 n = new Ex1( ) ;
n.PobierzImieOdUsera ( ) ;
n.PobierzPrzedmiotyIocene ( ) ;
n.SrednieOcen ( ) ;
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKY2xhc3MgRXgxIHsKICAgIHByaXZhdGUgU3RyaW5nIG5hbWU7CiAgICBwcml2YXRlIFN0cmluZ1tdIHN1YmplY3RzID0gbmV3IFN0cmluZ1szXTsKICAgIHByaXZhdGUgZmxvYXRbXVtdIG5vdGVzID0gbmV3IGZsb2F0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