sequence.cpp

#include "sequence.h" int main() { Sequence go; int size; int element = 0; vector<int> x; vector<int> y; go.read(x, y, size); go.print(x, y); go.add(x, y); go.subtract(x, y); go.multiply(x, y, element); go.equal(x, y); }

sequenceFunctions.cpp

#include "sequence.h" void Sequence::read(vector<int> &x, vector<int> &y, int size) { int tempInt; cout << "Please enter the number of integers you want for vector x: "; cin >> size; cout << "Please enter your integers: "; for (int a = 0; a < size; a++) { cin >> tempInt; x.push_back(tempInt); } cout << "Please enter the number of integers you want for vector y: "; cin >> size; cout << "Please enter your integers: "; for (int a = 0; a < size; a++) { cin >> tempInt; y.push_back(tempInt); } } void Sequence::print(vector<int> x, vector<int> y) { cout << "This is the sequence for vector x: ("; for (int a = 0; a < (x.size() - 1); a++) cout << x[a] << ", "; cout << x[x.size() - 1] << ")" << endl; cout << "This is the sequence for vector y: ("; for (int b = 0; b < (y.size() - 1); b++) cout << y[b] << ", "; cout << y[y.size() - 1] << ")" << endl; } void Sequence::putelement(vector<int> &y, int element) { y.insert(y.begin(), element); } void Sequence::add(vector<int> x, vector<int> y) { if (x.size() > y.size()) y.resize(x.size()); else if (y.size() > x.size()) x.resize(y.size()); cout << "Vector x + vector y = ("; for (int a = 0; a < (x.size() - 1); a++) cout << x[a] + y[a] << ", "; cout << x[x.size() - 1] + y[x.size() - 1] << ")." << endl; } void Sequence::subtract(vector<int> x, vector<int> y) { if (x.size() > y.size()) y.resize(x.size()); else if (y.size() > x.size()) x.resize(y.size()); cout << "Vector x - vector y = ("; for (int a = 0; a < (x.size() - 1); a++) cout << x[a] - y[a] << ", "; cout << x[x.size() - 1] - y[x.size() - 1] << ")." << endl; } void Sequence::multiply(vector<int> x, vector<int> y, int element) { Sequence go; char answer; cout << "Would you like to multiply by a constant? (y/n): "; cin >> answer; while (answer == 'y') { char vectorChoice; int integerChoice; cout << "Which vector would you like to use? (x/y): "; cin >> vectorChoice; cout << "Please choose an integer: "; cin >> integerChoice; if (vectorChoice == 'x') { cout << "Vector x * " << integerChoice << " = ("; for (int a = 0; a < (x.size() - 1); a++) cout << x[a] * integerChoice << ", "; cout << x[x.size() - 1] * integerChoice << ")." << endl; cout << "Would you like to multiply by a constant again? (y/n): "; cin >> answer; } else { cout << "Vector y * " << integerChoice << " = ("; for (int b = 0; b < (y.size() - 1); b++) cout << y[b] * integerChoice << ", "; cout << y[y.size() - 1] * integerChoice << ")." << endl; cout << "Would you like to multiply by a constant again? (y/n): "; cin >> answer; } } cout << "Would you like to multiply vectors x and y together? (y/n): "; cin >> answer; if (answer == 'y') { vector<int> temp1; vector<int> temp2; vector<int> temp3; for (int a = 0; a < x.size(); a++) { temp1.clear(); for (int b = 0; b < y.size(); b++) temp1.push_back(x[a] * y[b]); temp3.resize(temp1.size()); temp2 = temp3; temp3.clear(); for (int c = 0; c < temp1.size(); c++) temp3.push_back(temp1[c] + temp2[c]); go.putelement(y, element); } cout << "Vector x * vector y = ("; for (int d = 0; d < (temp3.size() - 1); d++) cout << temp3[d] << ", "; cout << temp3[temp3.size() - 1] << ")." << endl; } } bool Sequence::equal(vector<int> x,vector<int> y) { if (x == y) cout << "Vector x equals vector y." << endl; else cout << "Vector x does not equal vector y." << endl; }

sequence.h

#ifndef SEQUENCE_H_ #define SEQUENCE_H_ #include <iostream> #include <vector> using namespace std; class Sequence { public: void read(vector<int> &x, vector<int> &y, int size); void print(vector<int> x, vector<int> y); void putelement(vector<int> &y, int element); void add(vector<int> x, vector<int> y); void subtract(vector<int> x, vector<int> y); void multiply(vector<int> x, vector<int> y, int element); bool equal(vector<int> x, vector<int> y); }; #endif

Thanks in advance for the help guys.