Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 21.2, Problem 21.2.6CP

Suppose set1 is a set that contains the strings red, yellow, and green and that set2 is another set that contains the strings red, yellow, and blue. Answer the following questions:

  • What are in set1 and set2 after executing set1.addA11(set2)?
  • What are in set1 and set2 after executing set1.add(set2)?
  • What are in set1 and set2 after executing set1.removeA11(set2)?
  • What are in set1 and set2 after executing set1.remove(set2)?
  • What are in set1 and set2 after executing set1.retainAll(set2)?
  • What is in set1 after executing set1.clear()?
Blurred answer
Students have asked these similar questions
Create a Java Program that performs set operations. 1. The user first chooses any of the following options. a. Identify Elements of Set I. i. The user will list the elements of A and B, the maximum number of elements per set is 5 elements b. Check Union Value i. When chosen, the program will return the union value of A and B c. Check Difference i. When chosen, the program will return the value of the following: 1. A - B 2. B - A d. Check Intersection i. When chosen, the intersection of A and B will be displayed e. Check subset i. This time, the program will ask the user for a number and checks whether this number is a subset of A and B. f. Users cannot perform items b to e if A and B are empty sets. 2. Present the program usung flowchart. (CC102, MATHPLUS, GE1, ENGPLSUS, CC101)
Write a section of code that creates the pairings for two sets of numbers a = {0 – 5} and b = {9 - 15}.  Each number must be paired with all numbers from the other set.  This is a cross product, denoted as a x b.  That is, for every number in a, it should be listed with every number in b, such as (0, 9), … (0, 15), and so on.  Make sure there are no spaces between numbers and the (, ), or comma.
In java write code that will take in input from a user containing two sets. Then you will complete all 6 set operations on those sets. Your user input/output should look similar to the assignment Set Operations Assignment (which is attatched) The universal set is all integers from 1 to 100. Ideally your code would be able to accept all types of input but for practice we are going to stick to integers. You should test your code with more than the following inputs but I will be grading you based on if your code is able to accept the following as user input (one set/pair at a time) and give the correct output for the given set (do not hard code it for the all sets at once, the output should be determined by the code based on the input, meaning I could put any two set integers as input and it should work): S = {1, 2, 3, 4}   T = {3, 4, 5, 6} S = {1, 3, 5}   T = {3, 4, 5, 6} S = {10, 13, 22, 41}   T = {40, 60, 80} S = {3, 10}   T = {1, 2, 3} S = {10}   T = {3}

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
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
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License