fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner input = new Scanner(System.in);
  13. String[] nomes = new String[5];
  14. double[] notas = new double[5];
  15. double media=0, soma = 0;
  16.  
  17. for (int c = 0; c < nomes.length; c++) {
  18. System.out.println("Informe um nome:");
  19. nomes[c] = input.next();
  20. System.out.println("Informe a nota:");
  21. notas[c] = input.nextDouble();
  22. soma = soma + notas[c];
  23.  
  24. }
  25. media = soma / 5;
  26. System.out.println("A media da turma é: " + media);
  27. }
  28. }
Runtime error #stdin #stdout #stderr 0.15s 36556KB
stdin
Fulano de Tal
10
stdout
Informe um nome:
Informe a nota:
stderr
Exception in thread "main" java.util.InputMismatchException
	at java.base/java.util.Scanner.throwFor(Scanner.java:939)
	at java.base/java.util.Scanner.next(Scanner.java:1594)
	at java.base/java.util.Scanner.nextDouble(Scanner.java:2564)
	at Ideone.main(Main.java:21)