Program71.java 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. Program73.java In main: Declare an array capable of holding five first names. Populate the array in a for loop by entering five first names all on one line separated by spaces. sort the array alphabetically. Use a foreach loop (see page 255) to process the sorted array and display the names on one line separated by spaces. Execute a void method with the sorted array as its only argument. In the void method: Create an arraylist of Strings. Use a loop (of any type) to put the names in the array into the arraylist. Add another name (you choose it) at the end of the arraylist. Remove the name at the start of the arraylist. Add Abdul as the new name at the start of the arraylist. Use a foreach loop to process the arraylist and display the names all on one line separated by spaces. Sample Output (image below)

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

Program71.java

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.

Program73.java

In main:

  • Declare an array capable of holding five first names.
  • Populate the array in a for loop by entering five first names all on one line separated by spaces.
  • sort the array alphabetically.
  • Use a foreach loop (see page 255) to process the sorted array and display the names on one line separated by spaces.
  • Execute a void method with the sorted array as its only argument.

In the void method:

  • Create an arraylist of Strings.
  • Use a loop (of any type) to put the names in the array into the arraylist.
  • Add another name (you choose it) at the end of the arraylist.
  • Remove the name at the start of the arraylist.
  • Add Abdul as the new name at the start of the arraylist.
  • Use a foreach loop to process the arraylist and display the names all on one line separated by spaces.

Sample Output (image below)

Enter 5 names separated by spaces William Henry Juan Maria Sandra
Names in sorted array: Henry Juan Maria Sandra William
Final names in arraylist: Abdul Juan Maria Sandra William Zendaya
Transcribed Image Text:Enter 5 names separated by spaces William Henry Juan Maria Sandra Names in sorted array: Henry Juan Maria Sandra William Final names in arraylist: Abdul Juan Maria Sandra William Zendaya
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 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