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)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.2: Array Names As Pointers
Problem 4E: (Program) Write a declaration to store the following values in an array named rates: 12.9, 18.6,...
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.
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage