We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boa tarde, tudo bom ?
Esse exercício resolvi ele dessa forma, gostaria de feedback sobre ele se esta correto se tem algum ponto para ser melhorado
Scanner leitor = new Scanner(System.in); List temperaturas = new ArrayList<>();
String[] messes = new String[] { "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho" }; for (int i = 0; i < messes.length; i++) { System.out.print("Informe a temperatura de " + messes[i] + ": "); temperaturas.add(leitor.nextDouble()); } System.out.println("\nTodas as temperaturas: "); temperaturas.forEach(temp -> System.out.println(temp)); System.out.println("\nCalculando media: "); Double media = temperaturas .stream() .reduce(0d, (total, element) -> total + element) / messes.length; System.out.println(media); System.out.println("\nMeses com as temperaturas acima da média: "); Iterator<Double> iterator = temperaturas.iterator(); while (iterator.hasNext()) { Double temperatura = iterator.next(); if (temperatura >= media) { System.out.println(messes[temperaturas.indexOf(temperatura)] + " - " + temperatura + "oC"); } }
The text was updated successfully, but these errors were encountered:
Oi, @erickcred. Tudo certinho? Sim! É uma forma válida de resolver o exercício também.
Há formas de simplificar ainda mais o exercício, mas de começo, está ótimo!
Sorry, something went wrong.
No branches or pull requests
Boa tarde, tudo bom ?
Esse exercício resolvi ele dessa forma, gostaria de feedback sobre ele se esta correto se tem algum ponto para ser melhorado
Scanner leitor = new Scanner(System.in);
List temperaturas = new ArrayList<>();
The text was updated successfully, but these errors were encountered: