Advertisement
SIRAKOV4444

Untitled

Apr 11th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 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. double minO = Integer.MAX_VALUE;
  9. double maxO = Integer.MIN_VALUE;
  10. double minE = Integer.MAX_VALUE;
  11. double maxE = Integer.MIN_VALUE;
  12. double sumOdd = 0;
  13. double sumEven = 0;
  14.  
  15. for (int i = 1; i <= N; i++) {
  16. double current = Double.parseDouble(scanner.nextLine());
  17. if (current % 2 == 0) {
  18. sumEven += current;
  19.  
  20. if (maxE < current) {
  21. maxE = current;
  22.  
  23. }
  24. if (minE > current) {
  25. minE = current;
  26.  
  27. }
  28. } else {
  29. sumOdd += current;
  30.  
  31. if (maxO < current) {
  32. maxO = current;
  33.  
  34. }
  35. if (minO > current) {
  36. minO = current;
  37.  
  38.  
  39. }
  40.  
  41.  
  42. }
  43. }
  44. System.out.printf("OddSum=%.2f", sumOdd);
  45. System.out.printf("\nOddMin=%.2f", minE);
  46. System.out.printf("\nOddMax=%.2f", maxO);
  47. System.out.printf("\nEvenSum=%.2f", sumEven);
  48. System.out.printf("\nEvenMin=%.2f", minO);
  49. System.out.printf("\nEvenMax=%.2f", maxE);
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement