Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int iterations = 0, count2 = 0, j = 1, max = 0, min = 0, userInt = 0,
- sum = 0, even = 0,
- odd = 0;
- double mean = 0;
- do {
- System.out.println("Enter the number of loop iterations required: ");
- iterations = sc.nextInt();
- if (iterations <=0)
- System.out.println("Enter an integer greater than 0");
- } while (iterations <= 0);
- for (int i = 1; i <= iterations; i++) {
- count2 = iterations - (iterations - j);
- System.out.println("\n\nenter integer " + count2);
- userInt = sc.nextInt();
- sum += userInt;
- mean = (double)sum/(double)count2;
- System.out.println("mean of input " + count2 + " is: " + mean);
- if (count2 == 1) {
- max = userInt;
- min = userInt;
- }
- else {
- if (userInt > max) {
- max = userInt;
- }
- if (userInt < min) {
- min = userInt;
- }
- }
- System.out.println("max value is: " + max );
- System.out.println("min value is: " + min);
- if ((userInt % 2) == 0) {
- even += 1;
- }
- else {
- odd += 1;
- }
- System.out.println("even count: " + even);
- System.out.println("odd count " + odd);
- j++;
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement