I am missing a formula to make it odd; This same loop should determine how many integers in the array are odd numbers. After this loop ends, use this figure to declare a new array of integers named odds. Process the array again in the method, but this time with a foreach loop, and add the odd integers to the odds array. Return the odds array back to main. In main, report the size of the array and sort it ascending. Finally use a while loop to print the odd integers all on one line separated by spaces. I am also tring to make it 4 rows and 8 columns. This is what the professor wants: Write a program that creates a 32-element array of random integers all from 1 to 100, inclusive. Then execute a custom method with the array as its only argument. The method should begin by using a loop to print the array elements in 4 rows and 8 columns, with all columns being five characters wide. Duplicates are okay. This same loop should determine how many integers in the array are odd numbers. After this loop ends, use this figure to declare a new array of integers named odds. Process the array again in the method, but this time with a foreach loop, and add the odd integers to the odds array. Return the odds array back to main. In main, report the size of the array and sort it ascending. Finally use a while loop to print the odd integers all on one line separated by spaces. DOES NOT USE TEMPERATURE This is what I have so far: public static int[] oddNumbers(int[] r) {         int random = 0;           for (int i = 0; i < r.length; i++) {             if (i == 0 || i %5 != 0) {             System.out.print(r[i] + " ");}              else {                 System.out.println();                 System.out.print(r[i] + " ");                 }             if (r[i] < 32) {             random ++;             } }         int[] f_array = new int[random];         int ran = 0;         for (int i : r) {             if (i < 32) {                 f_array[ran] = i;                 ran ++;             }         }         return f_array; }     public static void main(String[] args) {         int[] arr = new int[32];         for (int i = 0; i < arr.length; i++) {             arr[i] = (int) (Math.random() * 100 - 10) + 10;         }          int[] res = oddNumbers(arr);         Arrays.sort(res);         System.out.println("\nPrinting the Sorted values.\n");         for (int i = 0; i < res.length; i++) {             if (i == res.length - 1) {             System.out.print(res[i]);}              else {                 System.out.print(res[i] + " ");                     }         }                 System.out.print("\n");     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I am missing a formula to make it odd; This same loop should determine how many integers in the array are odd numbers. After this loop ends, use this figure to declare a new array of integers named odds. Process the array again in the method, but this time with a foreach loop, and add the odd integers to the odds array. Return the odds array back to main. In main, report the size of the array and sort it ascending. Finally use a while loop to print the odd integers all on one line separated by spaces.

I am also tring to make it 4 rows and 8 columns.

This is what the professor wants: Write a program that creates a 32-element array of random integers all from 1 to 100, inclusive. Then execute a custom method with the array as its only argument. The method should begin by using a loop to print the array elements in 4 rows and 8 columns, with all columns being five characters wide. Duplicates are okay. This same loop should determine how many integers in the array are odd numbers. After this loop ends, use this figure to declare a new array of integers named odds. Process the array again in the method, but this time with a foreach loop, and add the odd integers to the odds array. Return the odds array back to main. In main, report the size of the array and sort it ascending. Finally use a while loop to print the odd integers all on one line separated by spaces.

DOES NOT USE TEMPERATURE

This is what I have so far:

public static int[] oddNumbers(int[] r) {
        int random = 0;
 
        for (int i = 0; i < r.length; i++) {
            if (i == 0 || i %5 != 0) {
            System.out.print(r[i] + " ");} 
            else {
                System.out.println();
                System.out.print(r[i] + " ");
                }

            if (r[i] < 32) {
            random ++;
            }
}
        int[] f_array = new int[random];

        int ran = 0;
        for (int i : r) {
            if (i < 32) {
                f_array[ran] = i;
                ran ++;
            }
        }

        return f_array;

}
    public static void main(String[] args) {

        int[] arr = new int[32];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100 - 10) + 10;
        } 
        int[] res = oddNumbers(arr);

        Arrays.sort(res);

        System.out.println("\nPrinting the Sorted values.\n");

        for (int i = 0; i < res.length; i++) {
            if (i == res.length - 1) {
            System.out.print(res[i]);} 
            else {
                System.out.print(res[i] + " ");
                    }
        }
                System.out.print("\n");
    }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education