Question: Java2 1)Complete violation() method to find list of students who have taken CS211 without taking CS210, a prerequisite for CS 211. 2) Complete CS210andCS211notCS212Classes() method

Java2

1)Complete violation() method to find list of students who have taken CS211 without taking CS210, a prerequisite for CS 211. 2) Complete CS210andCS211notCS212Classes() method to find list of students who have taken CS 210 and CS 211 but have not taken CS 212. Expected output: CS211 without taking CS 210: [kim] CS 210 and CS 211 but not CS 212: [Eva] Restrictions: You should NOT update the original HashSet. This is the set operation practice we studied yesterday. Only .addAll(), .retainAll(), .removeAll() should be used.

import java.util.*;

public class q5 {

static HashSet CS210 = new HashSet(); static HashSet CS211 = new HashSet(); static HashSet CS212 = new HashSet(); public static void Initialize() { CS210.add("Bill"); CS210.add("Eva"); CS210.add("Olivia"); CS211.add("Eva"); CS211.add("Olivia"); CS211.add("Kim"); CS212.add("Chloe"); CS212.add("Jane"); CS212.add("Olivia"); CS212.add("Bill"); }

public static void violation() { } public static void CS210andCS211notCS212Classes() { } public static void main(String[] args) { Initialize(); violation(); CS210andCS211notCS212Classes(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!