Advertisement
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());
- double minO = Integer.MAX_VALUE;
- double maxO = Integer.MIN_VALUE;
- double minE = Integer.MAX_VALUE;
- double maxE = Integer.MIN_VALUE;
- double sumOdd = 0;
- double sumEven = 0;
- for (int i = 1; i <= N; i++) {
- double current = Double.parseDouble(scanner.nextLine());
- if (current % 2 == 0) {
- sumEven += current;
- if (maxE < current) {
- maxE = current;
- }
- if (minE > current) {
- minE = current;
- }
- } else {
- sumOdd += current;
- if (maxO < current) {
- maxO = current;
- }
- if (minO > current) {
- minO = current;
- }
- }
- }
- System.out.printf("OddSum=%.2f", sumOdd);
- System.out.printf("\nOddMin=%.2f", minE);
- System.out.printf("\nOddMax=%.2f", maxO);
- System.out.printf("\nEvenSum=%.2f", sumEven);
- System.out.printf("\nEvenMin=%.2f", minO);
- System.out.printf("\nEvenMax=%.2f", maxE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement