File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
estatisticas-estudantes-estruturado/src/main/java
estatisticas-estudantes-funcional/src/main/java Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ public AppProgramacaoEstruturada(){
1414 estudantes = StudentGenerator .generate (TOTAL_STUDENTS );
1515
1616 imprimeMaiorNota ();
17+ imprimeMaiorNotaHomens ();
1718 imprimeMaiorHomens ();
1819 imprimeTotalHomens ();
1920 imprimeTotalMulheres ();
@@ -159,6 +160,16 @@ private void imprimeMaiorNota() {
159160 System .out .printf ("Maior nota entre todos os Estudantes: %.2f\n " , maiorNota );
160161 }
161162
163+ private void imprimeMaiorNotaHomens () {
164+ double maiorNota = 0 ;
165+ for (Estudante estudante : estudantes ) {
166+ if (estudante .getSexo () == 'M' && estudante .getNota () > maiorNota ) {
167+ maiorNota = estudante .getNota ();
168+ }
169+ }
170+ System .out .printf ("Maior nota eentre Homens: %.2f\n " , maiorNota );
171+ }
172+
162173 private void imprimeMaiorHomens () {
163174 double maiorNota = 0 ;
164175 for (Estudante estudante : estudantes ) {
Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ private void imprimeMaiorNota() {
4747 private void imprimeMaiorNotaHomens () {
4848 final double maior =
4949 estudantes .stream ()
50- .filter (Estudante :: isHomem )
51- .mapToDouble (Estudante :: getNota )
50+ .filter (( Estudante e ) -> e . getSexo () == 'M' )
51+ .mapToDouble (( Estudante e ) -> e . getNota () )
5252 .max ()
5353 .orElse (0 );
5454 System .out .printf ("Maior nota entre todos os Estudantes: %.2f\n " , maior );
You can’t perform that action at this time.
0 commit comments