TOPIC

Java Runtime Erro

mamarcelino0 asked 3 years ago

import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        Scanner leia = new Scanner(System.in);

        int valor = 0;

        for(int i = 1; i < 7; i++) {
            int a = leia.nextInt();
            if (a > 0)
                valor++;
        }

        if (valor == 1)
            System.out.println(valor + " valor posistivo");
        else
            System.out.println(valor + " valores posistivos");

        leia.close();   
    }
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • ncosta17 replied 3 years ago

    Verifique se seu código verifica apenas números inteiros positivos e negativos ou também números de ponto flutuante positivos e negativos

  • wsalvatore replied 3 years ago

    vocÊ deve imprimir "valores positivos" independente de ser 1 ou mais numeros...