(URI) Números Positivos - Solução
import java.io.*;
class Main {
public void processa() throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int countPositives = 0;
for (int i = 0; i < 6; i++) {
double num = Double.parseDouble(br.readLine());
if (num > 0) {
countPositives++;
}
}
System.out.println(countPositives + " valores positivos");
return;
}
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
}
class Main {
public void processa() throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int countPositives = 0;
for (int i = 0; i < 6; i++) {
double num = Double.parseDouble(br.readLine());
if (num > 0) {
countPositives++;
}
}
System.out.println(countPositives + " valores positivos");
return;
}
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
}
Comments
Post a Comment