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

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

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.

 

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT