1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gizmo_the_mogwai [7]
4 years ago
12

Have main create two objects: setA and setB.Input the values into setA (end with a 0 or negative) and input the values into setB

(end with 0 or negative).Print the ordered pairs using printOrderedPairs.Print if setA is a subset of setB.Then print if setA is a proper subset of setB.
Computers and Technology
1 answer:
kvasek [131]4 years ago
6 0

Answer:

C code is explained below

Explanation:

Sets.h:

#ifndef SETS_H

#define SETS_H

class Sets

{

    private:

         static const int s = 4;

         int na[s];

    public:

         //for constructor

         Sets();

         //function declaration for add the element

         void addElement(int);

         //function declaration for get the element

         int getElement(int);

         //function declaration for get size

         int getSize();

         //function declaration for check sub set

         bool isSubset(const Sets &);

         //function declaration for check the proper subset

         bool isProper(const Sets &);

         //function declaration for display the set

         void printSet();

         //function declaration for display the ordered set

         void Sets::printOrderedPairs( const Sets &);

};

#endif

Main.cpp:

#include "Sets.h"

#include <iostream>

using namespace std;

//constructor

Sets::Sets(){

   for (int i = 0; i < s; i++){

       na[i] = -1;

   }

}

//function definition for get size

int Sets::getSize(){

   return s;

}

//function definition for add the elements

void Sets::addElement(int l){

   for (int i = 0; i < s; i++){

       if (na[i] == -1){

           na[i] = l;

           break;

       }

   }

}

//function definition for get element

int Sets::getElement(int j){

   if (j < s){

       return (-1);

   }

   else{

       int t;

       t = na[j];

       return t;

   }

}

//function definition for check the subset

bool Sets::isSubset( const Sets &b ) {

  for (int i = 0, j = 0; i < b.s; i++ ) {

          while ( j < s && na[j] < b.na[i] ) ++j;

       if ( j == s || na[j] > b.na[i] )

           return false;

   }

   return true;

}

//function definition for check the proper subset

bool Sets::isProper( const Sets &b ) {

   int ne = 0;

   for (int i = 0, j = 0; i < b.s; i++ ) {

       while ( j < s && na[j] < b.na[i] ) ++j;

       if ( j == s || na[j] > b.na[i] )

           return false;

       ++ne;

   }

   return ne < s;

}

//function definition for display the ordered set

void Sets::printOrderedPairs( const Sets &b){

   cout << "A X B = {";

   for (int i = 0; i < s; i++){

       for (int j = 0; j < b.s; j++){

           cout << '(' << na[i] << ", " << b.na[j] << "), ";

     }

   }

   cout << "\b\b} ";

}

//function definition for display the set

void Sets::printSet(){

   cout << "{";

   for (int i = 0; i < s; i++){

       cout << na[i] << ",";

   }

   cout << "}";

}

//main function

int main()

{

   //object for Set A

   Sets a;

   //object for Set B

   Sets b;

   //add the element for Set A

   a.addElement(1);

   a.addElement(2);

   a.addElement(3);

   a.addElement(4);

    //add the element for Set B

   b.addElement(3);

   b.addElement(4);

   b.addElement(5);

   b.addElement(6);

   //display the set A

   cout << "Set A: ";

   a.printSet();

   cout << endl;

   //display the set B

   cout << "Set B: ";

   b.printSet();

   cout << "\n" << endl;

   //display the A X B

    a.printOrderedPairs(b);

   cout << "\n" << endl;

    //chrck the subset

   if (a.isSubset(b) == true){

       cout << "Set B is subset of set A" << endl;

   }

   else{

       cout << "Set B is not a subset of set A" << endl;

   }

    //check the proper subset

   if (a.isProper(b) == true){

       cout << "Set B is proper subset of set A" << endl;

   }

   else{

        cout << "Set B is not a proper subset of set A" << endl;

   }

   system("PAUSE");

   return 0;

}

You might be interested in
Anna has a physical mobility difference, and she uses virtual reality to complete her exercises. To use virtual reality, Anna ne
Zepler [3.9K]

Answer:

Explanation:

The basic concept of virtual reality is that they are a pair of lenses in a headset that allows you to visualize a virtual 3D world and become immersed within it. To do the exercises correctly Anna would need to follow the following basic steps.

Put the virtual glasses over her eyes, complete the exercises in the virtual world, take the virtual glasses off

The headset/glasses need to fit comfortably on her eyes and around her head so that she can clearly see the image on the lenses and so that the headset/glasses do not fall off while she is completing her exercises. Once she is done with her exercises Anna can simply take off her virtual glasses and put them away.

5 0
3 years ago
Did the first generation of computers use microprocessors.
Katena32 [7]

no they used standard 8088 Intel processors

hope this helps

8 0
2 years ago
Read 2 more answers
When was the bible of luke written​
Gelneren [198K]
85 C.E. I think that is when it was written, but I’m not 100% sure.
3 0
3 years ago
Which of the following statements is TRUE?
viktelen [127]

Answer:

3

Explanation:

5 0
3 years ago
Read 2 more answers
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hou
Nuetrik [128]

Answer:

Following is the program in the python language

hr = input("input hours:") #Read input by user

h1 = float(hr)

rate =input("Input Rate:") #Read RATE BY USER

r1 = float(rate) #CONVERT INTO FLOAT

if h1 <= 40: #check condition

   t=h1 * r1

   print (t) #DISPLAY

else :#else block

   t1=(40 * r1) + (h1 -40) * r1 * 1.5

   print('The pay is :')

   print(t1)#DISPLAY

Output:

input hours:45

Input Rate:10.50

The pay is :

498.75

Explanation:

Following are the description of program

  • Read the value of hour in the "hr" variable and convert into the float value in the "h1" variable .
  • Read the value of rate in the " rate" variable and convert into the float value in the "r1" variable .
  • After that check the condition of hour if block if the hour is less then or equal to 40 then it multiplied h1 *t1 otherwise else block will be executed and print the value of pay .

5 0
4 years ago
Other questions:
  • Interactive sites were usually is right about important topics and comments to a threaded discussion are called
    9·1 answer
  • Which is the most used operating system? A. Windows B.Linux C.Leopard D. DOS
    14·2 answers
  • An Administrator is preparing to deploy change set into the production environment. Until the deployment is complete, only user
    8·1 answer
  • Let T be the statement: The sum of any two rational numbers is rational. Then T is true, but the following "proof is incorrect.
    14·1 answer
  • A common approach of networking multiple computers as opposed to a single computer is? called:
    14·1 answer
  • 1. What runs horizontally and is identified with numbers?
    12·2 answers
  • The _________ lets you move the view of a web page up or down and left or right.
    13·2 answers
  • What is the main theme of The hundred dresses​
    14·2 answers
  • Olivia wants to change some settings in Outlook. What are the steps she will use to get to that function? open Outlook → File →
    7·2 answers
  • How do you get a blank business card template in word?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!