Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FORcleverLili {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int N = Integer.parseInt(scanner.nextLine());
- int minO = Integer.MAX_VALUE;
- int maxO = Integer.MIN_VALUE;
- int minE = Integer.MAX_VALUE;
- int maxE = Integer.MIN_VALUE;
- double sumOdd = 0;
- double sumEven = 0;
- for (int i = 1; i <= N; i++) {
- int current = Integer.parseInt(scanner.nextLine());
- if (current % 2 == 0) { //GLAVNO
- sumEven += current;
- } else {
- sumOdd += current;
- }
- if (maxE < current) {
- maxE = current;
- }
- if (minE > current) {
- minE = current;
- }
- if (maxO < current) {
- maxO = current;
- }
- if (minO > current) {
- minO = current;
- }
- }
- System.out.printf("OddSum= %.2f", sumOdd);
- System.out.printf("\nOddMin= %.2f",minO );
- System.out.printf("\nOddMax= %.2f", maxO);
- System.out.printf("\nEvenSum= %.2f", sumEven);
- System.out.printf("\nEvenMin= %.2f", minE);
- System.out.printf("\nEvenMax= %.2f", maxE);
- }
- }
Add Comment
Please, Sign In to add comment