SIRAKOV4444

Untitled

Apr 11th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FORcleverLili {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int N = Integer.parseInt(scanner.nextLine());
  8. int minO = Integer.MAX_VALUE;
  9. int maxO = Integer.MIN_VALUE;
  10. int minE = Integer.MAX_VALUE;
  11. int maxE = Integer.MIN_VALUE;
  12. double sumOdd = 0;
  13. double sumEven = 0;
  14.  
  15. for (int i = 1; i <= N; i++) {
  16. int current = Integer.parseInt(scanner.nextLine());
  17. if (current % 2 == 0) { //GLAVNO
  18. sumEven += current;
  19. } else {
  20. sumOdd += current;
  21. }
  22.  
  23. if (maxE < current) {
  24. maxE = current;
  25. }
  26. if (minE > current) {
  27. minE = current;
  28. }
  29. if (maxO < current) {
  30. maxO = current;
  31. }
  32. if (minO > current) {
  33. minO = current;
  34. }
  35. }
  36. System.out.printf("OddSum= %.2f", sumOdd);
  37. System.out.printf("\nOddMin= %.2f",minO );
  38. System.out.printf("\nOddMax= %.2f", maxO);
  39. System.out.printf("\nEvenSum= %.2f", sumEven);
  40. System.out.printf("\nEvenMin= %.2f", minE);
  41. System.out.printf("\nEvenMax= %.2f", maxE);
  42. }
  43. }
Add Comment
Please, Sign In to add comment