all questions in the file

1 answer below »
Answered 3 days AfterAug 26, 2021

Answer To: all questions in the file

Arun Shankar answered on Aug 30 2021
131 Votes
main.cpp
#include
#include
#include
#include "orderedpair.h"
using namespace std;
using namespace cs_
pairs;
int main()
{
int num1, num2;
OrderedPair myList[10];
srand(static_cast(time(0)));

cout << "default value: ";
myList[0].print();
cout << endl;

for (int i = 0; i < 10; i++)
{
myList[i].setFirst(rand() % 50);
myList[i].setSecond(rand() % 50 + 50);
}
myList[2] = myList[0] + myList[1];
if (myList[0] < myList[1])
{
myList[0].print();
cout << " is less than "; myList[1].print(); cout << endl;
}
for (int i = 0; i < 10; i++)
{
myList[i].print(); cout << endl;
}
cout << "Enter two numbers to use in an OrderedPair. Make sure they are different numbers: ";
cin >> num1 >> num2;

OrderedPair x;
/* use this before you've implemented the exception handling in the class: */
x.setFirst(num1);
x.setSecond(num2);

/* use this after you've implemented the exception handling in the class: */
try {
x.setFirst(num1); x.setSecond(num2);
} catch (OrderedPair::DuplicateMemberError e) { cout << "Error, you attempted to set both members of the OrderedPair to the same number." << endl; x.setFirst(OrderedPair::DEFAULT_VALUE); x.setSecond(OrderedPair::DEFAULT_VALUE);
}
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here