Answered Essay: 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 . . .

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

#include <iostream>
using namespace std;

int main() {

string setA[30];
string setB[30];

char choice = ‘’;
do {
cout << “Enter integers for set A (no more than 30 numbers, -1 to stop)”
<< endl;
string input;
int i = 0;
while (1) {
cout << i << “:”;
cin >> input;
if (input == “-1”) {
break;
} else {
setA[i] = input;
}
i++;
}

cout
<< “Enter characters for set B (no more than 30 characters, ‘.’ to stop)”
<< endl;
int j = 0;
while (1) {
cout << j << “:”;
cin >> input;
if (input == “.”) {
break;
} else {
setB[j] = input;
}
j++;
}

cout << “set A = { “;
for (int k = 0; k < i; k++) {
cout << setA[k];
if (k < i – 1)
cout << “,”;
}
cout << ” }” << endl;

cout << “set B = { “;
for (int k = 0; k < j; k++) {
cout << setB[k];
if (k < j – 1)
cout << “,”;
}
cout << ” }” << endl;

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

for (int k = 0; k < i; k++) {
for (int l = 0; l < j; l++) {
cout << “( ” << setA[k] << “, ” << setB[l] << ” )”;
if ((l < j – 1) || (k < i – 1))
cout << “, “;
}
}
cout << “}” << endl;
cout << “Again (y/n):”;
cin >> choice;
} while (choice == ‘y’);
return 0;
}

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

OUTPUT:-

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

Enter integers for set A (no more than 30 numbers, -1 to stop)
0:2
1:3
2:4
3:-1
Enter characters for set B (no more than 30 characters, ‘.’ to stop)
0:w
1:r
2:t
3:y
4:q
5:.
set A = { 2,3,4 }
set B = { w,r,t,y,q }
The Cartesian product 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

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

Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

Try it now!

Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.