EBK C HOW TO PROGRAM
EBK C HOW TO PROGRAM
8th Edition
ISBN: 9780133964639
Author: Deitel
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
bartleby

Concept explainers

Question
Book Icon
Chapter 17, Problem 17.21E
Program Plan Intro

Program plan:

  • Define class IntegerSet. Inside this class,
    • Include a private data member setwhich is an array of size 100of type int.
    • Include a constructor to initialize above data member to zero.
    • Provide a function insertElement to addinteger element to the set.
    • Provide a function deleteElement to delete an element fromthe set.
    • Provide a function unionOfSets to find union of two integer sets.
    • Provide a function intersectionOfSets to find intersection of two integer sets.
    • Provide a function isEmpty to check if the set is empty.
    • Provide a function isEqualTo to check if two sets are equal.
    • Provide a function printSet to print the values in the set.
  • Define a main function. Inside main function,
    • Define four objects set1, set2, set3 and set4 of IntegerSet class.
    • Use all of IntegerSet class functions on these objects.

Program Description: The following program will create aIntegerSet class to represent the set of integers numbers and include functions for operations on two integer sets.

Blurred answer
Students have asked these similar questions
(Tic-Tac-Toe) Write a program that allows two players to play the tic-tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.
Activity: Create a collection of objects using Java generics.  use java to write code. Create a Month class that can accept integer or String data type as an argument. The parameter type will be decided at run time. For this exercise, we will use Month class to store integer and string values that contains 12 months. For example, the integer value of 12 corresponds to string value of “December.” Use the following minimal class definition for Month class. public class Month<T> { private T month; public void setMonth(T month); public T getMonth(); }; Create a new class, MonthApp. This new class will have main method, and will instantiate Month objects to store month indices and names. Here is an example using arrays. // defineMonth<Integer>[] monthsByNumber = new Month<>[12];Month<String>[] monthsByName = new Month<>[12];// adding valuesmonthsByNumber[0] = new Month<Integer>();monthsByNumber[0].setMonth(1);monthsByName[0] = new…
(Geometry: MyRectangle2D class)  Define the  MyRectangle2D class that contains:  Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to the x- or y-axis.) The data fields width and height with getter and setter methods. A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A Constructor that creates a rectangle with the specified x, y, width, and height. A method getArea() that returns the area of the rectangle. A method getPerimeter() that returns the perimeter of the rectangle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a ). A method contains(MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure 10.24b ). A method overlaps(MyRectangle2D r) that returns true if the specified rectangle overlaps with this…
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning