Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
Write a Java program to work with two arrays and perform operations on them.
Your program should have 2 methods:
int[] union (int[] al, int[] a2): takes two integer arrays and returns a new
integer array consisting of all ints that appear in either a1 or a2. The returned array
should be appropriately sized and should contain any duplicate ints since everything
from both a1 and a2 should be in there. The returned array should not have any empty
spots and should be sorted numerically.
●
●
int[] intersection (int[] al, int[] a2): takes two integer arrays and returns a
new integer array consisting of all ints that appear in both a1 and a2. The returned array
should be appropriately sized and sorted numerically, and it should not contain any
duplicate ints or empty spots.
For example, when a1 = {1,2,3,4,5} and a2 {1,5,6,7,8}, union (al, a2) will return
{1,1,2,3,4,5,5,6,7,8} and intersection (al, a2) will return {1,5}.
=
Provide the following menu using a do..while loop in the main method to the user.
1. Union
2. Intersection
3. Exit
Before the menu pops up for the user, the main method should collect the input for the 2
arrays and create the arrays. After the user picks a menu choice, the main method should call
the appropriate method to do the work requested. Since these methods return new arrays to
the caller, the printing of the output of the new array should also be done by the main method.
expand button
Transcribed Image Text:Write a Java program to work with two arrays and perform operations on them. Your program should have 2 methods: int[] union (int[] al, int[] a2): takes two integer arrays and returns a new integer array consisting of all ints that appear in either a1 or a2. The returned array should be appropriately sized and should contain any duplicate ints since everything from both a1 and a2 should be in there. The returned array should not have any empty spots and should be sorted numerically. ● ● int[] intersection (int[] al, int[] a2): takes two integer arrays and returns a new integer array consisting of all ints that appear in both a1 and a2. The returned array should be appropriately sized and sorted numerically, and it should not contain any duplicate ints or empty spots. For example, when a1 = {1,2,3,4,5} and a2 {1,5,6,7,8}, union (al, a2) will return {1,1,2,3,4,5,5,6,7,8} and intersection (al, a2) will return {1,5}. = Provide the following menu using a do..while loop in the main method to the user. 1. Union 2. Intersection 3. Exit Before the menu pops up for the user, the main method should collect the input for the 2 arrays and create the arrays. After the user picks a menu choice, the main method should call the appropriate method to do the work requested. Since these methods return new arrays to the caller, the printing of the output of the new array should also be done by the main method.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education