Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include #include using namespace std; int menu() { int operation; cout > operat

ID: 3759790 • Letter: #

Question

#include #include using namespace std; int menu() { int operation; cout > operation; return operation; } void add(int a, int b, int c, int d, int numerator, int denominator) { numerator = (a*d) + (b*c); denominator = b*d; } void subtract(int a, int b, int c, int d, int numerator, int denominator) { numerator = (a*d) - (b*c); denominator = b*d; } void multiply(int a, int b, int c, int d, int numerator, int denominator) { numerator = a*c; denominator = b*d; } void divide(int a, int b, int c, int d, int numerator, int denominator) { numerator = a*d; denominator = b*c; } void main() { int a, b, c, d; int numerator, denominator; do { int operation = menu(); switch (operation) { case 1: cout > a; cout > b; if (b == 0) { cout > b; } cout > c; cout > d; if (d == 0) { cout > d; } add(a, b, c, d, numerator, denominator); cout > a; cout > b; if (b == 0) { cout > b; } cout > c; cout > d; if (d == 0) { cout > d; } subtract(a, b, c, d, numerator, denominator); cout > a; cout > b; if (b == 0) { cout > b; } cout > c; cout > d; if (d == 0) { cout > d; } multiply(a, b, c, d, numerator, denominator); cout > a; cout > b; if (b == 0) { cout > b; } cout > c; cout > d; if (d == 0) { cout > d; } divide(a, b, c, d, numerator, denominator); cout << "(" << a << " / " << b << ")" << " / " << "(" << c << " / " << d << ")" << " = " << numerator << " / " << denominator << endl; break; } cout << endl << " Enter to try again... " << endl;

I am trying to run it on visual studio for C++, but there is error regarding the end of the code which I could not solve. plese help me to run the program

Explanation / Answer

#include<iostream>
using namespace std;
int menu() {
    int operation;
    cin>> operation;
    return operation;
}
void add(int a, int b, int c, int d, int numerator, int denominator) {
    numerator = (a * d) + (b * c);
    denominator = b * d;
}
void subtract(int a, int b, int c, int d, int numerator, int denominator) {
    numerator = (a * d) - (b * c);
    denominator = b * d;
}
void multiply(int a, int b, int c, int d, int numerator, int denominator) {
    numerator = a * c;
    denominator = b * d;
}
void divide(int a, int b, int c, int d, int numerator, int denominator) {
    numerator = a * d;
    denominator = b * c;
}
int main() {
    int a, b, c, d;
    int numerator, denominator;
    //do {
        int operation = menu();
        switch (operation) {
            case 1:
                cin>> a;
                cin >> b;
                if (b == 0) {
                    cin >> b;
                }
                cin >> c;
                cin >> d;
                if (d == 0) {
                    cin >> d;
                }
                add(a, b, c, d, numerator, denominator);
                cin >> a;
                cin >> b;
                if (b == 0) {
                    cin >> b;
                }
                cin >> c;
                cin >> d;
                if (d == 0) {
                    cin >> d;
                }
                subtract(a, b, c, d, numerator, denominator);
                cin >> a;
                cin >> b;
                if (b == 0) {
                    cin >> b;
                }
                cin >> c;
                cin >> d;
                if (d == 0) {
                    cin >> d;
                }
                multiply(a, b, c, d, numerator, denominator);
                cin >> a;
                cin >> b;
                if (b == 0) {
                    cin >> b;
                }
                cin >> c;
                cin >> d;
                if (d == 0) {
                    cin >> d;
                }
                divide(a, b, c, d, numerator, denominator);
                cout << "(" << a << " / " << b << ")" << " / " << "(" << c << " / " << d << ")" << " = " << numerator << " / " << denominator << endl;
                break;
        }
        cout << endl << " Enter to try again... " << endl;
    //}
}