TOPIC

java8. Presentation error

ndias18 asked 3 years ago

Pq meu codigo da "Presentation error"???

import java.util.Locale; import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    Locale.setDefault(Locale.US);
    Scanner sc = new Scanner(System.in);

    double x;
    int totalPositive = 0;

    for (int i = 0; i < 6; i++) {
        x = sc.nextDouble();
        if (x > 0) {
            totalPositive += 1;
        }
    }

    System.out.println(totalPositive + " valores positivos\n");

    sc.close();

}

}

This topic was solved and cannot recieve new replies.

  • ndias18 replied 3 years ago

    Valeeu! Deu certo aqui! =D

  • Instagram-pedro_leocir replied 3 years ago

    Boa tarde Natália, não programo muito em Java e posso estar falando abobrinha ... mas o println vai fazer uma quebra de linha no final ... Então tu teria duas opções.

    1 - System.out.println(totalPositive + " valores positivos"); sem o \n uma vez que o println vai fazer essa quebra automática

    2 - System.out.printf(totalPositive + " valores positivos\n"); Os dois deram aceito.

    MOD