#include <iostream>
#ifdef _WIN32
#define CLEAR "cls"
#elif __linux__
#define CLEAR "clear"
#endif
int main(void) {
int operation, num1a, num1b, num2a, num2b;
std::string menu { "\nOPERATIONS\n----------\n 1) Addition\n 2) Subtraction\n 3) Multiplication\n 4) Division\nEnter operation: " };
std::cout << menu;
std::cin >> operation ;
while (operation < 1 || operation > 4) {
system(CLEAR);
std::cout << "\nINVALID INPUT. PLEASE RE-ENTER\n------------------------------\n" << std::endl;
std::cout << menu;
std::cin >> operation;
}
if (operation == 1) {
int sum, num1a, num1b, num2a, num2b;
float quotient1, quotient2;
// FIRST FRACTION SET
std::cout << "\nPerforming Addition\n-------------------\n\nFIRST FRACTION SET" << std::endl;
std::cout << "Enter num1: ";
std::cin >> num1a;
std::cout << "Enter num2: ";
std::cin >> num2a;
while (num2a == 0) {
std::cout << "\nERROR! DIVISION BY ZERO!" << std::endl;
std::cout << "Please re-enter num2: ";
std::cin >> num2a;
}
quotient1 = (float) num1a / (float) num2a;
// SECOND FRACTION SET
std::cout << "\nSECOND FRACTION SET" << std::endl;
std::cout << "Enter num1: ";
std::cin >> num1b;
std::cout << "Enter num2: ";
std::cin >> num2b;
while (num2b == 0) {
std::cout << "\nERROR! DIVISION BY ZERO!" << std::endl;
std::cout << "Please re-enter num2: ";
std::cin >> num2b;
}
quotient2 = (float) num1b / (float) num2b;
std::cout << "\nThe SUM of " << num1a << "/" << num2a << " and " << num1b << "/" << num2b << " is " << quotient1+quotient2 << "\n" << std::endl;
}
return 0;
}