PART A: Note: The following code is written only in main -- you assume there is an array bag and you are not adding any methods to that bag. Write the main program to create two array bags of type string. Place 5 strings of your choice in the first bag and 5 strings (of your choice) in the second bag.  Your program must: 1) determine if there are any strings in the first bag that appears in the second bag as well. If there are, print there are repeated strings. Else print the bags have unique values. 2) Print the content of the both bags and if there are repeated values, print that value only once.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

PART A:

Note: The following code is written only in main -- you assume there is an array bag and you are not adding any methods to that bag.

Write the main program to create two array bags of type string. Place 5 strings of your choice in the first bag and 5 strings (of your choice) in the second bag.  Your program must:
1) determine if there are any strings in the first bag that appears in the second bag as well. If there are, print there are repeated strings. Else print the bags have unique values.

2) Print the content of the both bags and if there are repeated values, print that value only once.

 

PART B:

Create two linkedBag objects of type string in main. Place 5 strings in the first bag and five strings in the second bag. Then your code must test if the two linkedBag objects are equal or not. You must traverse both linkedBags and test each items to see if they are the same.

Then you must display a message saying the two linkedBags are the same or different.

 

PART C:

Write a method in the linkedBag class that gets an item of type T and finds out how many of the items in the linkedBag are bigger than that item. Return that count.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage