URI Problem (Even, Odd, Positive and Negative) 1066:
Even, Odd, Positive and Negative is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
import java.util.Scanner;
/**
* @Author : Muhammad Harun-Or-Roshid
* @Date : Oct 14, 2016
* @Time : 9:22:14 PM
*/
public class Uri1066 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int values[] = new int[5];
int pos = 0, neg = 0, even = 0, odd = 0;
for (int i = 0; i < values.length; i++) {
values[i] = sc.nextInt();
if (values[i] > 0) {
pos++;
}
if (values[i] < 0) {
neg++;
}
if (values[i] % 2 == 0) {
even++;
} else {
odd++;
}
}
System.out.println(even + " valor(es) par(es)");
System.out.println(odd + " valor(es) impar(es)");
System.out.println(pos + " valor(es) positivo(s)");
System.out.println(neg + " valor(es) negativo(s)");
}
}
0 Comments