Homework Solution: Write a C++ program to list all elements in the Cartesian product of these two sets. You will ask user to ent…

    Write a C++ program to list all elements in the Cartesian product of these two sets. You will ask user to enter the elements of each set (A and B), then display the Cartesian product of A and B. Turn in the C++ source code (not project file or solution file), with three test cases. Note: set A and B can hold string elements, double, and/or character datatype. It is your choice. Following is an example of A holds integer and B holds characters. Example of program output: This program lists all elements in the Cartesian product of sets A and B. For example: Let A = {1, 2, 3} Let B = {a, b} The Cartesian product is: A X B = { (1, a), (1, b), (2, a), (2, b), (3, a), (3, b) } Enter integers for set A (no more than 30 numbers, -1 to stop) 1: 1 2: 2 3: 3 4: -1 Enter characters for set B (no more than 30 characters, '.' to stop) 1: a 2: b 3: . set A = {   1,   2,   3 } set B = {   a,   b } The Cartesian product of A and B is A X B = { ( 1, a ),   ( 1, b ),   ( 2, a ),   ( 2, b ),   ( 3, a ), ( 3, b ) } Again (y/n): y Enter integers for set A (no more than 30 numbers, -1 to stop) 1: 2 2: 4 3: 6 4: 8 5: -1 Enter characters for set B (no more than 30 characters, '.' to stop) 1: x 2: y 3: z 4: . set A = {   2,   4,   6,   8 } set B = {   x,   y,   z } The Cartesian product of A and B is A X B = { ( 2, x ),   ( 2, y ),   ( 2, z ),   ( 4, x ),   ( 4, y ), ( 4, z ),   ( 6, x ),   ( 6, y ),   ( 6, z ),   ( 8, x ), ( 8, y ),   ( 8, z ) } Again (y/n): n Press any key to continue . . .

    Expert Answer

     
    Hi Let me know if you need more information:- ======================================== #include <iostream>

    Write a C++ program to roll every elements in the Cartesian fruit of these span determineds. You conciliate petition user to invade the elements of each determined (A and B), then flaunt the Cartesian fruit of A and B. Turn in the C++ commencement code (not attributable device refine or disruption refine), with three standard cases. Not attributable attributablee: determined A and B can endure string elements, envelop, and/or temperament datatype. It is your excellent. Following is an copy of A endures integer and B endures temperaments.

    Copy of program output:

    This program rolls every elements in the Cartesian fruit of determineds A and B.

    Coercion copy: Let A = {1, 2, 3}

    Let B = {a, b}

    The Cartesian fruit is:

    A X B = { (1, a), (1, b), (2, a), (2, b), (3, a), (3, b) }

    Invade integers coercion determined A (no over than 30 gum, -1 to plug)

    1: 1

    2: 2

    3: 3

    4: -1

    Invade temperaments coercion determined B (no over than 30 temperaments, ‘.’ to plug)

    1: a

    2: b

    3: .

    determined A = {   1,   2,   3 }

    determined B = {   a,   b }

    The Cartesian fruit of A and B is

    A X B = {

    ( 1, a ),   ( 1, b ),   ( 2, a ),   ( 2, b ),   ( 3, a ), ( 3, b ) }

    Again (y/n): y

    Invade integers coercion determined A (no over than 30 gum, -1 to plug)

    1: 2

    2: 4

    3: 6

    4: 8

    5: -1

    Invade temperaments coercion determined B (no over than 30 temperaments, ‘.’ to plug)

    1: x

    2: y

    3: z

    4: .

    determined A = {   2,   4,   6,   8 }

    determined B = {   x,   y,   z }

    The Cartesian fruit of A and B is

    A X B = {

    ( 2, x ),   ( 2, y ),   ( 2, z ),   ( 4, x ),   ( 4, y ), ( 4, z ),   ( 6, x ),   ( 6, y ),   ( 6, z ),   ( 8, x ), ( 8, y ),   ( 8, z ) }

    Again (y/n): n

    Press any explanation to endure . . .

    Expert Response

     

    Hi Let me perceive if you need over information:-

    ========================================

    #include <iostream>
    using namespace std;

    int main() {

    string determinedA[30];
    string determinedB[30];

    char excellent = ‘’;
    do {
    cout << “Invade integers coercion determined A (no over than 30 gum, -1 to plug)”
    << endl;
    string input;
    int i = 0;
    suitableness (1) {
    cout << i << “:”;
    cin >> input;
    if (input == “-1”) {
    break;
    } else {
    setA[i] = input;
    }
    i++;
    }

    cout
    << “Invade temperaments coercion determined B (no over than 30 temperaments, ‘.’ to plug)”
    << endl;
    int j = 0;
    suitableness (1) {
    cout << j << “:”;
    cin >> input;
    if (input == “.”) {
    break;
    } else {
    setB[j] = input;
    }
    j++;
    }

    cout << “determined A = { “;
    coercion (int k = 0; k < i; k++) {
    cout << determinedA[k];
    if (k < i – 1)
    cout << “,”;
    }
    cout << ” }” << endl;

    cout << “determined B = { “;
    coercion (int k = 0; k < j; k++) {
    cout << determinedB[k];
    if (k < j – 1)
    cout << “,”;
    }
    cout << ” }” << endl;

    cout << “The Cartesian fruit of A and B is” << endl;
    cout << “A X B = { ” << endl;

    coercion (int k = 0; k < i; k++) {
    coercion (int l = 0; l < j; l++) {
    cout << “( ” << determinedA[k] << “, ” << determinedB[l] << ” )”;
    if ((l < j – 1) || (k < i – 1))
    cout << “, “;
    }
    }
    cout << “}” << endl;
    cout << “Again (y/n):”;
    cin >> excellent;
    } suitableness (excellent == ‘y’);
    return 0;
    }

    ===============

    OUTPUT:-

    =====================

    Invade integers coercion determined A (no over than 30 gum, -1 to plug)
    0:2
    1:3
    2:4
    3:-1
    Invade temperaments coercion determined B (no over than 30 temperaments, ‘.’ to plug)
    0:w
    1:r
    2:t
    3:y
    4:q
    5:.
    determined A = { 2,3,4 }
    determined B = { w,r,t,y,q }
    The Cartesian fruit of A and B is
    A X B = {
    ( 2, w ), ( 2, r ), ( 2, t ), ( 2, y ), ( 2, q ), ( 3, w ), ( 3, r ), ( 3, t ), ( 3, y ), ( 3, q ), ( 4, w ), ( 4, r ), ( 4, t ), ( 4, y ), ( 4, q )}
    Again (y/n):n

    ======================