#include "FunctionLib.h"
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::stringstream;
using std::getline;
int main()
{
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text(" CALCULATOR ", color_green);
print_text(" Version 1.3 BETA ", color_blue);
print_text("-----------------------------", color_red);
print_text("(1) detect_simple_operation ", color_blue);
print_text("(2) do_algebra ", color_yellow);
print_text("(3) order_of_ops ", color_red);
print_text("(4) Calculator version & info", color_orange);
print_text("-----------------------------", color_red); print(">>> ", color_green, color_black);
string op; cin >> op;
cin.ignore();
if(op == "detect_simple_operation" || op == "1" || op == "(1)")
{
detector();
}
else if(op == "do_algebra" || op == "2" || op == "(2)")
{
//if the user wants algebra
//asks to do 1-variable, 2-variable, or 3-variable algebra
print_text("----------------------", color_red);
print_text("(1)1_variable ", color_green);
print_text("(2)2_variable ", color_red);
print_text("(3)3_variable ", color_orange);
print_text("----------------------", color_red); print(">>> ", color_green, color_black);
string algebra_choice;
cin >> algebra_choice;
cin.ignore();
if(algebra_choice == "1" || algebra_choice == "(1)" || algebra_choice == "1_variable")
{
algebra_1();
}
else if(algebra_choice == "2" || algebra_choice == "(2)" || algebra_choice == "2_variable")
{
algebra_2();
}
else if(algebra_choice == "3" || algebra_choice == "(3)" || algebra_choice == "3_variable")
{
algebra_3();
}
else
{
print_text("--------------------------------------", color_red);
print_text("Please enter a valid choice next time.", color_red);
print_text("--------------------------------------", color_red);
main();
}
}
else if(op == "3" || op == "(3)" || op == "order_of_ops")
{
print_text("--------------------------------------", color_red);
print_text("Welcome to this expression simplifier!", color_green);
print_text("--------------------------------------", color_red);
print_text("(1) algebraic_simplifier ", color_yellow);
print_text("(2) reguar_order_of_ops ", color_blue);
print_text("------------------------ ", color_red); print(">>> ", color_green, color_black);
cin >> op;
cin.ignore();
if(op == "1" || op == "(1)" || op == "algebraic_simplifier")
{
print_text("----------------------", color_red);
print_text("(1)1_variable ", color_green);
print_text("(2)2_variable ", color_red);
print_text("(3)3_variable ", color_orange);
print_text("----------------------", color_red); print(">>> ", color_green, color_black);
string algebra_choice;
cin >> algebra_choice;
cin.ignore();
if(algebra_choice == "1" || algebra_choice == "(1)" || algebra_choice == "1_variable")
{
algebra_1();
}
else if(algebra_choice == "2" || algebra_choice == "(2)" || algebra_choice == "2_variable")
{
algebra_2();
}
else if(algebra_choice == "3" || algebra_choice == "(3)" || algebra_choice == "3_variable")
{
algebra_3();
}
else
{
print_text("--------------------------------------", color_red);
print_text("Please enter a valid choice next time.", color_red);
print_text("--------------------------------------", color_red);
main();
}
}
else if(op == "2" || op == "(2)" || op == "reguar_order_of_ops")
{
string snow = order_of_ops();
if(snow == "detector") detector();
else if(snow == "error" || snow == "done");
}
else
{
print_text("----------------------------", color_red);
print_text("Please enter a valid choice.", color_red);
print_text("----------------------------", color_red);
main();
}
}
else if(op == "4" || op == "(4)")
{
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("Calculator Version: 1.3 BETA ", color_blue);
print_text("-----------------------------------------------------------------", color_red);
print_text("GUI Custimization: Fully integrated! ", color_green);
print(">",color_green, color_black); print(">",color_blue, color_black); print(">",color_red, color_black); print_color_test();
print_text("Operation Status: Not fully functional. ", color_red);
print_text("Working: detect_simple_operation ", color_green);
print_text("Partially working: 1 variable algebra, order of ops ", color_yellow);
print_text("Not working: 2, 3 variable algebra, algebra expression simplifier", color_red);
print_text("-----------------------------------------------------------------", color_red);
print_text("Designed and built by peteboy_2007 in C++ ", color_light_blue);
print_text("-----------------------------------------------------------------", color_red);
print_text("Official Release deadline: Jan 1, 2022 (extendable) ", color_green);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
int coo = info();
if(coo == 0) main();
else if(coo == 1) return 0;
}
else
{
print_text("--------------------------------------------", color_red);
print_text("Please enter a valid operator and try again.", color_red);
print_text("--------------------------------------------", color_red);
main();
}
print_text("-------------------------------", color_blue);
print_text("Do you want to try again? (y/n)", color_light_blue);
print_text("-------------------------------", color_blue); print(">>> ", color_green, color_black);
string choice;
cin >> choice;
if(choice == "y")
{
cin.ignore();
main();
}
else if(choice == "n")
{
cin.ignore();
print_text("-------------------------------", color_blue);
return 0;
}
else
{
print_text("--------------------------------------------", color_red);
print_text("Please enter a valid choice next time. (y/n)", color_red);
print_text("--------------------------------------------", color_red);
main();
}
return 0;
}
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <stdio.h>
#include <math.h>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::stringstream;
using std::getline;
int find_num_of_chars(string array[], string char_to_find, int array_size)
{
int i = 0;
int boo;
int num_of_chars = 0;
do
{
string term = array[i];
boo = term.find(char_to_find);
if(boo != -1)
{
num_of_chars = num_of_chars + 1;
}
else;
i = i + 1;
}
while(i < array_size);
if(num_of_chars == 0) return -1;
else return num_of_chars;
}
string order_of_ops()
{
int temp_var = 0;
int check = 0;
string term;
print_text("=======================================", color_red);
print_text("How many terms do you wish to simplify?", color_blue);
print_text("=======================================", color_red); print(">>> ", color_green, color_black);
int ops_termnumm;
cin >> ops_termnumm;
cin.ignore();
if(ops_termnumm <= 15);
else
{
print_text(":::::::::::::::", color_red);
print_text("Too many terms.", color_dark_red);
print_text(":::::::::::::::", color_red);
return "error";
}
if(ops_termnumm == 2)
{
return "detector";
}
else;
int ops_termnum = (ops_termnumm * 2) - 1;
string ops_expression[ops_termnum];
print_text("*************************************", color_red);
print_text("Enter your terms separated by spaces.", color_blue);
print_text("_____________________________________", color_dark_blue); print(">>> ", color_green, color_black);
int i = 0;
do
{
cin >> ops_expression[i];
i++;
}
while(i < ops_termnum);
i = 0;
cin.ignore();
string ops_check_array[ops_termnumm];
string tmp;
do
{
if((i % 2) == 1);
else ops_check_array[i / 2] = ops_expression[i];
i++;
}
while(i < ops_termnum);
i = 0;
if(numbers_only_array(ops_check_array, ops_termnumm, true) == true);
else
{
print_text("ERROR: unrecognized character detected.", color_dark_red);
return "error";
}
//operator finder module lines 90 - 308;
int add_times = find_num_of_chars(ops_expression, "+", ops_termnum);
int minus_times = find_num_of_chars(ops_expression, "-", ops_termnum);
int times_times = find_num_of_chars(ops_expression, "*", ops_termnum);
int divide_times = find_num_of_chars(ops_expression, "/", ops_termnum);
int add_found[add_times];
int minus_found[minus_times];
int times_found[times_times];
int divide_found[divide_times];
if(add_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("+");
if(temp_var == 0)
{
add_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
if(minus_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("-");
if(temp_var == 0)
{
minus_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
else;
if(times_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("*");
if(temp_var == 0)
{
times_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
else;
if(divide_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("/");
if(temp_var == 0)
{
divide_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
else;
}
else if(minus_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("-");
if(temp_var == 0)
{
minus_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
if(times_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("*");
if(temp_var == 0)
{
times_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
else;
if(divide_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("/");
if(temp_var == 0)
{
divide_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
else;
}
else if(times_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("*");
if(temp_var == 0)
{
times_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
if(divide_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("/");
if(temp_var == 0)
{
divide_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
}
else if(divide_times != -1)
{
do
{
if(i % 2 == 1)
{
term = ops_expression[i];
temp_var = term.find("/");
if(temp_var == 0)
{
divide_found[check] = i;
check = check + 1;
}
else;
}
else;
i++;
}
while(i < ops_termnum);
}
else
{
cout << "---------------\n";
cout << "Error: OPS_OPNF\n";
cout << "---------------\n";
}
//operator to term attacher module lines 294 - 590;
//variable initilazations;
long double ops_solution;
string term_1_attached[2];
string term_2_attached[2];
string term_3_attached[2];
string term_4_attached[2];
string term_5_attached[2];
string term_6_attached[2];
string term_7_attached[2];
string term_8_attached[2];
string term_9_attached[2];
string term_10_attached[2];
string term_11_attached[2];
string term_12_attached[2];
string term_13_attached[2];
string term_14_attached[2];
string term_15_attached[2];
//variable assignments and configuration;
if(ops_termnumm == 3)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
}
else if(ops_termnumm == 4)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
}
else if(ops_termnumm == 5)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
}
else if(ops_termnumm == 6)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
}
else if(ops_termnumm == 7)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
}
else if(ops_termnumm == 8)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
}
else if(ops_termnumm == 9)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
}
else if(ops_termnumm == 10)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
term_10_attached[1] = ops_expression[18];
term_10_attached[0] = ops_expression[17];
}
else if(ops_termnumm == 11)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
term_10_attached[1] = ops_expression[18];
term_10_attached[0] = ops_expression[17];
term_11_attached[1] = ops_expression[20];
term_11_attached[0] = ops_expression[19];
}
else if(ops_termnumm == 12)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
term_10_attached[1] = ops_expression[18];
term_10_attached[0] = ops_expression[17];
term_11_attached[1] = ops_expression[20];
term_11_attached[0] = ops_expression[19];
term_12_attached[1] = ops_expression[22];
term_12_attached[0] = ops_expression[21];
}
else if(ops_termnumm == 13)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
term_10_attached[1] = ops_expression[18];
term_10_attached[0] = ops_expression[17];
term_11_attached[1] = ops_expression[20];
term_11_attached[0] = ops_expression[19];
term_12_attached[1] = ops_expression[22];
term_12_attached[0] = ops_expression[21];
term_13_attached[1] = ops_expression[24];
term_13_attached[0] = ops_expression[23];
}
else if(ops_termnumm == 14)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
term_10_attached[1] = ops_expression[18];
term_10_attached[0] = ops_expression[17];
term_11_attached[1] = ops_expression[20];
term_11_attached[0] = ops_expression[19];
term_12_attached[1] = ops_expression[22];
term_12_attached[0] = ops_expression[21];
term_13_attached[1] = ops_expression[24];
term_13_attached[0] = ops_expression[23];
term_14_attached[1] = ops_expression[26];
term_14_attached[0] = ops_expression[25];
}
else if(ops_termnumm == 15)
{
term_1_attached[0] = "+";
term_1_attached[1] = ops_expression[0];
term_2_attached[1] = ops_expression[2];
term_2_attached[0] = ops_expression[1];
term_3_attached[1] = ops_expression[4];
term_3_attached[0] = ops_expression[3];
term_4_attached[1] = ops_expression[6];
term_4_attached[0] = ops_expression[5];
term_5_attached[1] = ops_expression[8];
term_5_attached[0] = ops_expression[7];
term_6_attached[1] = ops_expression[10];
term_6_attached[0] = ops_expression[9];
term_7_attached[1] = ops_expression[12];
term_7_attached[0] = ops_expression[11];
term_8_attached[1] = ops_expression[14];
term_8_attached[0] = ops_expression[13];
term_9_attached[1] = ops_expression[16];
term_9_attached[0] = ops_expression[15];
term_10_attached[1] = ops_expression[18];
term_10_attached[0] = ops_expression[17];
term_11_attached[1] = ops_expression[20];
term_11_attached[0] = ops_expression[19];
term_12_attached[1] = ops_expression[22];
term_12_attached[0] = ops_expression[21];
term_13_attached[1] = ops_expression[24];
term_13_attached[0] = ops_expression[23];
term_14_attached[1] = ops_expression[26];
term_14_attached[0] = ops_expression[25];
term_15_attached[1] = ops_expression[28];
term_15_attached[0] = ops_expression[27];
}
else
{
cout << "----------------\n";
cout << "Error: OPS_OPATT\n";
cout << "----------------\n";
order_of_ops();
}
//combining like terms and outputting, lines 592 - ;
stringstream stupid_60(term_1_attached[1]);
long double term_1;
stupid_60 >> term_1;
stringstream stupid_61(term_2_attached[1]);
long double term_2;
stupid_61 >> term_2;
stringstream stupid_62(term_3_attached[1]);
long double term_3;
stupid_62 >> term_3;
if(ops_termnumm == 3)
{
if(term_2_attached[0] == "+" || term_2_attached[0] == "-")
{
if(term_2_attached[0] == "-")
{
term_2 = term_2 * -1;
}
if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-")
{
term_3 = term_3 * -1;
}
ops_solution = term_1 + term_2 + term_3;
}
else if(term_3_attached[0] == "*")
{
if(term_2_attached[0] == "-")
{
ops_solution = term_1 - (term_2 * term_3);
}
else if(term_2_attached[0] == "+")
{
ops_solution = term_1 + (term_2 * term_3);
}
}
else if(term_3_attached[0] == "/")
{
if(term_2_attached[0] == "-")
{
ops_solution = term_1 - (term_2 / term_3);
}
else if(term_2_attached[0] == "+")
{
ops_solution = term_1 + (term_2 / term_3);
}
}
}
else if(term_2_attached[0] == "*")
{
if(term_3_attached[0] == "/")
{
ops_solution = (term_1 * term_2) / term_3;
}
else if(term_3_attached[0] == "*")
{
ops_solution = term_1 * term_2 * term_3;
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
ops_solution = (term_1 * term_2) + term_3;
}
}
else if(term_2_attached[0] == "/")
{
if(term_3_attached[0] == "/")
{
ops_solution = term_1 / term_2 / term_3;
}
else if(term_3_attached[0] == "*")
{
ops_solution = term_1 / (term_2 * term_3);
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
ops_solution = (term_1 / term_2) + term_3;
}
}
}
else if(ops_termnumm == 4)
{
stringstream stupid_63(term_4_attached[1]);
long double term_4;
stupid_63 >> term_4;
if(term_2_attached[0] == "+" || term_2_attached[0] == "-")
{
if(term_2_attached[0] == "-")
{
term_2 = term_2 * -1;
}
if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_4_attached[0] == "*") ops_solution = term_1 + term_2 + (term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = term_1 + term_2 + (term_3 / term_4);
else if(term_4_attached[0] == "+") ops_solution = term_1 + term_2 + term_3 + term_4;
else if(term_4_attached[0] == "-") ops_solution = (term_1 + term_2 + term_3) - term_4;
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "*") ops_solution = term_1 + (term_2 * term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = term_1 + (term_2 * term_3) / term_4;
else if(term_4_attached[0] == "+") ops_solution = term_1 + (term_2 * term_3) + term_4;
else if(term_4_attached[0] == "-") ops_solution = (term_1 + (term_2 * term_3)) - term_4;
}
else if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "*") ops_solution = term_1 + (term_2 / (term_3 * term_4));
else if(term_4_attached[0] == "/") ops_solution = term_1 + (term_2 / term_3 / term_4);
else if(term_4_attached[0] == "+") ops_solution = term_1 + (term_2 / term_3) + term_4;
else if(term_4_attached[0] == "-") ops_solution = (term_1 + (term_2 / term_3)) - term_4;
}
}
else if(term_2_attached[0] == "*")
{
if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "+") ops_solution = ((term_1 * term_2) / term_3) + term_4;
else if(term_4_attached[0] == "-") ops_solution = ((term_1 * term_2) / term_3) - term_4;
else if(term_4_attached[0] == "*") ops_solution = (term_1 * term_2) / (term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = (term_1 * term_2) / term_3 / term_4;
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "+") ops_solution = (term_1 * term_2 * term_3) + term_4;
else if(term_4_attached[0] == "-") ops_solution = (term_1 * term_2 * term_3) - term_4;
else if(term_4_attached[0] == "*") ops_solution = term_1 * term_2 * term_3 * term_4;
else if(term_4_attached[0] == "/") ops_solution = (term_1 * term_2 * term_3) / term_4;
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
if(term_4_attached[0] == "+") ops_solution = (term_1 * term_2) + term_3 + term_4;
else if(term_4_attached[0] == "-") ops_solution = ((term_1 * term_2) + term_3) - term_4;
else if(term_4_attached[0] == "*") ops_solution = (term_1 * term_2) + (term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = (term_1 * term_2) + (term_3 / term_4);
}
}
else if(term_2_attached[0] == "/")
{
if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "+") ops_solution = (term_1 / term_2 / term_3) + term_4;
else if(term_4_attached[0] == "-") ops_solution = (term_1 / term_2 / term_3) - term_4;
else if(term_4_attached[0] == "*") ops_solution = term_1 / term_2 / (term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = term_1 / term_2 / term_3 / term_4;
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "+") ops_solution = (term_1 / (term_2 * term_3)) + term_4;
else if(term_4_attached[0] == "-") ops_solution = (term_1 / (term_2 * term_3)) - term_4;
else if(term_4_attached[0] == "*") ops_solution = term_1 / (term_2 * term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = term_1 / (term_2 * term_3) / term_4;
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
if(term_4_attached[0] == "+") ops_solution = (term_1 / term_2) + term_3 + term_4;
else if(term_4_attached[0] == "-") ops_solution = ((term_1 / term_2) + term_3) - term_4;
else if(term_4_attached[0] == "*") ops_solution = (term_1 / term_2) + (term_3 * term_4);
else if(term_4_attached[0] == "/") ops_solution = (term_1 / term_2) + (term_3 / term_4);
}
}
}
else if(ops_termnumm == 5)
{
stringstream stupid_64(term_4_attached[1]);
long double term_4;
stupid_64 >> term_4;
stringstream stupid_65(term_5_attached[1]);
long double term_5;
stupid_65 >> term_5;
if(term_2_attached[0] == "+" || term_2_attached[0] == "-")
{
if(term_2_attached[0] == "-")
{
term_2 = term_2 * -1;
}
if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-")
{
term_3 = term_3 * -1;
}
if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + term_2 + (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + term_2 + (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + term_2 + (term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + term_2 + (term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + term_2 + (term_3 / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + term_2 + (term_3 / term_4 / term_5);
}
}
else if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + term_2 + term_3 + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + term_2 + term_3 + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + term_2 + term_3 + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 + term_2 + term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 + term_2 + term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 + term_2 + term_3) - (term_4 / term_5);
}
}
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 * term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 * term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + ((term_2 * term_3 * term_4) / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + ((term_2 * term_3) / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + ((term_2 * term_3) / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + ((term_2 * term_3) / term_4 / term_5);
}
}
else if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 * term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 * term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 * term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 + (term_2 * term_3)) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 + (term_2 * term_3)) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 + (term_2 * term_3)) - (term_4 / term_5);
}
}
}
else if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 / (term_3 * term_4)) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 / (term_3 * term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 / (term_3 * term_4) / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 / term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 / term_3 / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 / term_3 / term_4 / term_5);
}
}
else if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 + (term_2 / term_3)) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 + (term_2 / term_3)) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 + (term_2 / term_3)) - (term_4 / term_5);
}
}
}
}
else if(term_2_attached[0] == "*")
{
if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2) / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2) / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] =="/")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2) / (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2) / (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2) / (term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2) / (term_3 / term_4)) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2) / term_3 / (term_4 * term_5);
}
else if (term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2) / term_3 / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2 * term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2 * term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2 * term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2 * term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2 * term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 * term_2 * term_3 * term_4 * term_5;
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) * (term_4 / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2 * term_3) / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2 * term_3) / (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
if(term_4_attached[0] == "+")
{
ops_solution = (term_1 * term_2) + term_3 + term_4;
}
else if(term_4_attached[0] == "-")
{
ops_solution = ((term_1 * term_2) + term_3) - term_4;
}
else if(term_4_attached[0] == "*")
{
ops_solution = (term_1 * term_2) + (term_3 * term_4);
}
else if(term_4_attached[0] == "/")
{
ops_solution = (term_1 * term_2) + (term_3 / term_4);
}
}
}
else if(term_2_attached[0] == "/")
{
if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2 / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2 / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2 / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2 / term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2 / term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2 / term_3) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 / term_2 / (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / term_2 / (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / term_2 / (term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2 / term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / term_2 / term_3 / (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / term_2 / term_3 / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3)) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / (term_2 * term_3)) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / (term_2 * term_3)) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3)) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / (term_2 * term_3)) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / (term_2 * term_3)) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3 * term_4)) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / (term_2 * term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / (term_2 * term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3) / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / (term_2 * term_3) / (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / (term_2 * term_3) / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2) + term_3 + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2) + term_3 + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2) + term_3 + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 / term_2) + term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = ((term_1 / term_2) + term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = ((term_1 / term_2) + term_3) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2) + (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2) + (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2) + ((term_3 * term_4) / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2) + (term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2) + (term_3 / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2) + (term_3 / term_4 / term_5);
}
}
}
}
}
else if(ops_termnumm == 6)
{
stringstream stupid_64(term_4_attached[1]);
long double term_4;
stupid_64 >> term_4;
stringstream stupid_65(term_5_attached[1]);
long double term_5;
stupid_65 >> term_5;
stringstream stupid_66(term_6_attached[1]);
long double term_6;
stupid_66 >> term_6;
if(term_2_attached[0] == "+" || term_2_attached[0] == "-")
{
if(term_2_attached[0] == "-")
{
term_2 = term_2 * -1;
}
if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-")
{
term_3 = term_3 * -1;
}
if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + term_2 + (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + term_2 + (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + term_2 + (term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + term_2 + (term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + term_2 + (term_3 / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + term_2 + (term_3 / term_4 / term_5);
}
}
else if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + term_2 + term_3 + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + term_2 + term_3 + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + term_2 + term_3 + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 + term_2 + term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 + term_2 + term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 + term_2 + term_3) - (term_4 / term_5);
}
}
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 * term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 * term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + ((term_2 * term_3 * term_4) / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + ((term_2 * term_3) / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + ((term_2 * term_3) / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + ((term_2 * term_3) / term_4 / term_5);
}
}
else if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 * term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 * term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 * term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 + (term_2 * term_3)) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 + (term_2 * term_3)) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 + (term_2 * term_3)) - (term_4 / term_5);
}
}
}
else if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 / (term_3 * term_4)) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 / (term_3 * term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 / (term_3 * term_4) / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 / term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 / term_3 / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 / term_3 / term_4 / term_5);
}
}
else if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 + (term_2 / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 + (term_2 / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 + (term_2 / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 + (term_2 / term_3)) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 + (term_2 / term_3)) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 + (term_2 / term_3)) - (term_4 / term_5);
}
}
}
}
else if(term_2_attached[0] == "*")
{
if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2) / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2) / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] =="/")
{
ops_solution = ((term_1 * term_2) / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2) / (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2) / (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2) / (term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2) / (term_3 / term_4)) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2) / term_3 / (term_4 * term_5);
}
else if (term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2) / term_3 / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2 * term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2 * term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2 * term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2 * term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 * term_2 * term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 * term_2 * term_3 * term_4 * term_5;
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) * (term_4 / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 * term_2 * term_3) / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 * term_2 * term_3) / (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 * term_2 * term_3) / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
if(term_4_attached[0] == "+")
{
ops_solution = (term_1 * term_2) + term_3 + term_4;
}
else if(term_4_attached[0] == "-")
{
ops_solution = ((term_1 * term_2) + term_3) - term_4;
}
else if(term_4_attached[0] == "*")
{
ops_solution = (term_1 * term_2) + (term_3 * term_4);
}
else if(term_4_attached[0] == "/")
{
ops_solution = (term_1 * term_2) + (term_3 / term_4);
}
}
}
else if(term_2_attached[0] == "/")
{
if(term_3_attached[0] == "/")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2 / term_3) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2 / term_3) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2 / term_3) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2 / term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2 / term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2 / term_3) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = term_1 / term_2 / (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / term_2 / (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / term_2 / (term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2 / term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / term_2 / term_3 / (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / term_2 / term_3 / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "*")
{
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3)) + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / (term_2 * term_3)) + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / (term_2 * term_3)) + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3)) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / (term_2 * term_3)) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / (term_2 * term_3)) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3 * term_4)) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / (term_2 * term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / (term_2 * term_3 * term_4) / term_5;
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / (term_2 * term_3) / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = term_1 / (term_2 * term_3) / (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = term_1 / (term_2 * term_3) / term_4 / term_5;
}
}
}
else if(term_3_attached[0] == "+" || term_3_attached[0] == "-")
{
if(term_3_attached[0] == "-") term_3 = term_3 * -1;
if(term_4_attached[0] == "+")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2) + term_3 + term_4 + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2) + term_3 + (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2) + term_3 + (term_4 / term_5);
}
}
else if(term_4_attached[0] == "-")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = ((term_1 / term_2) + term_3) - (term_4 + term_5);
}
else if(term_5_attached[0] == "*")
{
ops_solution = ((term_1 / term_2) + term_3) - (term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = ((term_1 / term_2) + term_3) - (term_4 / term_5);
}
}
else if(term_4_attached[0] == "*")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2) + (term_3 * term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2) + (term_3 * term_4 * term_5);
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2) + ((term_3 * term_4) / term_5);
}
}
else if(term_4_attached[0] == "/")
{
if(term_5_attached[0] == "+" || term_5_attached[0] == "-")
{
if(term_5_attached[0] == "-") term_5 = term_5 * -1;
ops_solution = (term_1 / term_2) + (term_3 / term_4) + term_5;
}
else if(term_5_attached[0] == "*")
{
ops_solution = (term_1 / term_2) + (term_3 / (term_4 * term_5));
}
else if(term_5_attached[0] == "/")
{
ops_solution = (term_1 / term_2) + (term_3 / term_4 / term_5);
}
}
}
}
}
else if(ops_termnumm == 7)
{
}
else if(ops_termnumm == 8)
{
}
else if(ops_termnumm == 9)
{
}
else if(ops_termnumm == 10)
{
}
else if(ops_termnumm == 11)
{
}
else if(ops_termnumm == 12)
{
}
else if(ops_termnumm == 13)
{
}
else if(ops_termnumm == 14)
{
}
else if(ops_termnumm == 15)
{
}
else
{
print_text("--------------", color_red);
print_text("Error: OPS_CLT", color_red);
print_text("--------------", color_red);
order_of_ops();
}
string ops_solution_str;
stringstream stupid_67;
stupid_67 << ops_solution;
ops_solution_str = stupid_67.str();
print_text("------", color_blue);
print_text(ops_solution_str, color_green);
print_text("------", color_blue);
return "done";
}
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include "Color_text.h"
#include "order_of_ops.h"
#include "algebra.h"
#include "functions.h"
#include <string>
#include <iostream>
#include <cctype>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#include <Windows.h>
#endif // _WIN32
using namespace std;
#define color_black 0
#define color_dark_blue 1
#define color_dark_green 2
#define color_light_blue 3
#define color_dark_red 4
#define color_magenta 5
#define color_orange 6
#define color_light_gray 7
#define color_gray 8
#define color_blue 9
#define color_green 10
#define color_cyan 11
#define color_red 12
#define color_pink 13
#define color_yellow 14
#define color_white 15
bool numbers_only(string funcsake, bool allow_operators)
{
int i = 0;
string target;
if(allow_operators == false)
{
do
{
target = funcsake.substr(i, 1);
if(target == "1");
else if(target == "2");
else if(target == "3");
else if(target == "4");
else if(target == "5");
else if(target == "6");
else if(target == "7");
else if(target == "8");
else if(target == "9");
else if(target == "0");
else return false;
i++;
}
while(i < funcsake.size());
}
else
{
do
{
target = funcsake.substr(i, 1);
if(target == "1");
else if(target == "2");
else if(target == "3");
else if(target == "4");
else if(target == "5");
else if(target == "6");
else if(target == "7");
else if(target == "8");
else if(target == "9");
else if(target == "0");
else if(target == "-");
else if(target == "+");
else return false;
i++;
}
while(i < funcsake.size());
}
return true;
}
bool numbers_only_array(string array[], int sz, bool allow_operators)
{
int i = 0;
string tmp;
do
{
tmp = array[i];
if(numbers_only(tmp, allow_operators) == false) return false;
i++;
}
while(i < sz);
return true;
}
void print(const string s="") {
cout << s << endl;
}
void print(const string s, const int textcolor, const int backgroundcolor) {
#if defined(_WIN32)
CONSOLE_SCREEN_BUFFER_INFO csbi;
WORD default_colors = 0;
if(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) default_colors = csbi.wAttributes;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), backgroundcolor<<4|textcolor);
#elif defined(__linux__)
string t, b;
switch(textcolor) {
case 0: t="30"; break; // color_black 0
case 1: t="34"; break; // color_dark_blue 1
case 2: t="32"; break; // color_dark_green 2
case 3: t="36"; break; // color_light_blue 3
case 4: t="31"; break; // color_dark_red 4
case 5: t="35"; break; // color_magenta 5
case 6: t="33"; break; // color_orange 6
case 7: t="37"; break; // color_light_gray 7
case 8: t="90"; break; // color_gray 8
case 9: t="94"; break; // color_blue 9
case 10: t="92"; break; // color_green 10
case 11: t="96"; break; // color_cyan 11
case 12: t="91"; break; // color_red 12
case 13: t="95"; break; // color_pink 13
case 14: t="93"; break; // color_yellow 14
case 15: t="97"; break; // color_white 15
default: t="97";
}
switch(backgroundcolor) {
case 0: b= "40"; break; // color_black 0
case 1: b= "44"; break; // color_dark_blue 1
case 2: b= "42"; break; // color_dark_green 2
case 3: b= "46"; break; // color_light_blue 3
case 4: b= "41"; break; // color_dark_red 4
case 5: b= "45"; break; // color_magenta 5
case 6: b= "43"; break; // color_orange 6
case 7: b= "47"; break; // color_light_gray 7
case 8: b="100"; break; // color_gray 8
case 9: b="104"; break; // color_blue 9
case 10: b="102"; break; // color_green 10
case 11: b="106"; break; // color_cyan 11
case 12: b="101"; break; // color_red 12
case 13: b="105"; break; // color_pink 13
case 14: b="103"; break; // color_yellow 14
case 15: b="107"; break; // color_white 15
default: b= "40";
}
cout << "\033["+t+";"+b+"m";
#endif // Windows/Linux
cout << s;
#if defined(_WIN32)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), default_colors);
#elif defined(__linux__)
cout << "\033[0m"; // reset color
#endif // Windows/Linux
}
void wait() {
cin.get();
}
void print_color_test() {
print(" ", color_black, color_magenta );
print(" ", color_black, color_blue );
print(" ", color_black, color_light_blue);
print(" ", color_black, color_cyan );
print(" ", color_black, color_green );
print(" ", color_black, color_yellow );
print(" ", color_black, color_orange );
print(" ", color_black, color_red );
print(" ", color_black, color_black );
print(" ", color_black, color_gray );
print(" ", color_black, color_light_gray);
print(" ", color_black, color_white );
print(" ", color_black, color_pink );
print(" ", color_black, color_dark_blue );
print(" ", color_black, color_dark_green);
print(" ", color_black, color_dark_red );
print("#", color_magenta , color_black);
print("#", color_blue , color_black);
print("#", color_light_blue, color_black);
print("#", color_cyan , color_black);
print("#", color_green , color_black);
print("#", color_yellow , color_black);
print("#", color_orange , color_black);
print("#", color_red , color_black);
print("#", color_black , color_black);
print("#", color_gray , color_black);
print("#", color_light_gray, color_black);
print("#", color_white , color_black);
print("#", color_pink , color_black);
print("#", color_dark_blue , color_black);
print("#", color_dark_green, color_black);
print("#", color_dark_red , color_black);
print();
}
void print_text(const string s, const int textcolor)
{
int backgroundcolor;
#if defined(_WIN32)
CONSOLE_SCREEN_BUFFER_INFO csbi;
WORD default_colors = 0;
if(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) default_colors = csbi.wAttributes;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_black<<4|textcolor);
#elif defined(__linux__)
string t, b;
switch(textcolor) {
case 0: t="30"; break; // color_black 0
case 1: t="34"; break; // color_dark_blue 1
case 2: t="32"; break; // color_dark_green 2
case 3: t="36"; break; // color_light_blue 3
case 4: t="31"; break; // color_dark_red 4
case 5: t="35"; break; // color_magenta 5
case 6: t="33"; break; // color_orange 6
case 7: t="37"; break; // color_light_gray 7
case 8: t="90"; break; // color_gray 8
case 9: t="94"; break; // color_blue 9
case 10: t="92"; break; // color_green 10
case 11: t="96"; break; // color_cyan 11
case 12: t="91"; break; // color_red 12
case 13: t="95"; break; // color_pink 13
case 14: t="93"; break; // color_yellow 14
case 15: t="97"; break; // color_white 15
default: t="97";
}
switch(backgroundcolor) {
case 0: b= "40"; break; // color_black 0
case 1: b= "44"; break; // color_dark_blue 1
case 2: b= "42"; break; // color_dark_green 2
case 3: b= "46"; break; // color_light_blue 3
case 4: b= "41"; break; // color_dark_red 4
case 5: b= "45"; break; // color_magenta 5
case 6: b= "43"; break; // color_orange 6
case 7: b= "47"; break; // color_light_gray 7
case 8: b="100"; break; // color_gray 8
case 9: b="104"; break; // color_blue 9
case 10: b="102"; break; // color_green 10
case 11: b="106"; break; // color_cyan 11
case 12: b="101"; break; // color_red 12
case 13: b="105"; break; // color_pink 13
case 14: b="103"; break; // color_yellow 14
case 15: b="107"; break; // color_white 15
default: b= "40";
}
cout << "\033["+t+";"+b+"m";
#endif // Windows/Linux
cout << s << "\n";
#if defined(_WIN32)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), default_colors);
#elif defined(__linux__)
cout << "\033[0m"; // reset color
#endif // Windows/Linux
}
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <stdio.h>
#include <math.h>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::stringstream;
using std::getline;
string posc(string suit[], string fc, int sz, int termpos_posinterm_both)
{
string term;
int var_found;
int i = 0;
do
{
term = suit[i];
var_found = term.find(fc);
stringstream ss;
ss << i;
string i_s = ss.str();
stringstream sa;
sa << var_found;
string var_found_s = sa.str();
if(var_found != -1)
{
string member_1 = i_s;
string member_2 = var_found_s;
string comma = ", ";
if(termpos_posinterm_both == 0) return i_s;
else if(termpos_posinterm_both == 1) return var_found_s;
else if(termpos_posinterm_both == 2)
{
string complete_member = member_1.append(comma);
complete_member = complete_member.append(member_2);
return complete_member;
}
else;
}
else
i = i + 1;
}
while (i <= sz);
return "error";
}
void algebra_1()
{
print_text("-----------------------", color_red);
print_text("(1)equation ", color_green);
print_text("(2)expression ", color_dark_red);
print_text("-----------------------", color_red); print(">>> ", color_green, color_black);
long double al_1_solution;
string al_1_eqorex;
cin >> al_1_eqorex;
if(al_1_eqorex == "equation" || al_1_eqorex == "1" || al_1_eqorex == "(1)")
{
print_text("-----------------------------------------------------------", color_red);
print_text("Enter your equation like example. EX: ** (+,-,*,/) ** = ** ", color_light_blue);
print_text("Please only use 3 term equations in the layout shown above.", color_dark_red);
print_text("-----------------------------------------------------------", color_red); print(">>> ", color_green, color_black);
string al_1_equation[5];
for(int i = 0; i <= 4; i++)
{
cin >> al_1_equation[i];
}
print_text("----------------------------------------", color_red);
print_text("What character represents your variable?", color_blue);
print_text("----------------------------------------", color_red); print(">>> ", color_green, color_black);
string al_1_variable;
cin >> al_1_variable;
for(int i = 0; i <= 5; i++)
{
string var = al_1_equation[i];
int al_1_var_found = var.find(al_1_variable);
if(al_1_var_found != -1)
{
int var_arraypos_termpos[2] = {i, al_1_var_found};
break;
}
else;
}
print_text("-----------------------------------------------------", color_red);
print_text("How many times is your variable used in the equation?", color_blue);
print_text("-----------------------------------------------------", color_red); print(">>> ", color_green, color_black);
int al_1_var_times;
cin >> al_1_var_times;
bool err = false;
if(al_1_var_times == 1)
{
string var_pos = posc(al_1_equation, al_1_variable, 5, 2);
stringstream stupid(var_pos.substr(0,1));
int al_1_var_array_pos_int;
stupid >> al_1_var_array_pos_int;
string al_1_term_with_var_s = al_1_equation[al_1_var_array_pos_int];
int al_1_var_pos_in_term = al_1_term_with_var_s.find(al_1_variable);
string al_1_char_before_var_s;
int al_1_char_before_var;
if(al_1_var_pos_in_term == 0)
{
al_1_char_before_var_s = " ";
al_1_char_before_var = -1;
}
else if(al_1_var_pos_in_term == -1)
{
print_text("------------------------------------------", color_red);
print_text("Failed to find variable. Please try again.", color_dark_red);
print_text("------------------------------------------", color_red);
err = true;
algebra_1();
}
else
{
al_1_char_before_var_s = al_1_term_with_var_s.substr(al_1_var_pos_in_term - 1,1);
stringstream stupid_1(al_1_char_before_var_s);
stupid_1 >> al_1_char_before_var;
}
int array[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
if(al_1_char_before_var == array[0] || al_1_char_before_var == array[1] || al_1_char_before_var == array[2] || al_1_char_before_var == array[3] || al_1_char_before_var == array[4] || al_1_char_before_var == array[5] || al_1_char_before_var == array[6] || al_1_char_before_var == array[7] || al_1_char_before_var == array[8] || al_1_char_before_var == array[9])
{
string al_1_num_before_var = al_1_term_with_var_s.erase(al_1_term_with_var_s.size() - 1);
string al_1_equals_pos = posc(al_1_equation, "=", 5, 0);
if(al_1_equals_pos == "3")
{
int add_found = al_1_equation[1].find("+");
int minus_found = al_1_equation[1].find("-");
int times_found = al_1_equation[1].find("*");
int divide_found = al_1_equation[1].find("/");
stringstream stupid_28(al_1_num_before_var);
long double al_1_num_before_var_int;
stupid_28 >> al_1_num_before_var_int;
if(al_1_term_with_var_s.append(al_1_variable) == al_1_equation[0])
{
if(add_found != -1)
{
stringstream stupid_29(al_1_equation[2]);
long double mx_add_term_1;
stupid_29 >> mx_add_term_1;
stringstream stupid_30(al_1_equation[4]);
long double mx_add_term_2;
stupid_30 >> mx_add_term_2;
long double mx_inversed_pre_solution_add = mx_add_term_2 - mx_add_term_1;
al_1_solution = mx_inversed_pre_solution_add / al_1_num_before_var_int;
}
else if(minus_found != -1)
{
stringstream stupid_31(al_1_equation[2]);
long double mx_minus_term_1;
stupid_31 >> mx_minus_term_1;
stringstream stupid_32(al_1_equation[4]);
long double mx_minus_term_2;
stupid_32 >> mx_minus_term_2;
long double mx_inversed_pre_solution_minus = mx_minus_term_2 + mx_minus_term_1;
al_1_solution = mx_inversed_pre_solution_minus / al_1_num_before_var_int;
}
else if(times_found != -1)
{
stringstream stupid_33(al_1_equation[2]);
long double mx_times_term_1;
stupid_33 >> mx_times_term_1;
stringstream stupid_34(al_1_equation[4]);
long double mx_times_term_2;
stupid_34 >> mx_times_term_2;
long double mx_inversed_pre_solution_times = mx_times_term_2 / mx_times_term_1;
al_1_solution = mx_inversed_pre_solution_times / al_1_num_before_var_int;
}
else if(divide_found != -1)
{
stringstream stupid_35(al_1_equation[2]);
long double mx_divide_term_1;
stupid_35 >> mx_divide_term_1;
stringstream stupid_36(al_1_equation[4]);
long double mx_divide_term_2;
stupid_36 >> mx_divide_term_2;
long double mx_inversed_pre_solution_divide = mx_divide_term_2 * mx_divide_term_1;
al_1_solution = mx_inversed_pre_solution_divide / al_1_num_before_var_int;
}
else
{
print_text("------------------------------------------------------------------------------------------------------", color_red);
print_text("Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.", color_red);
print_text("------------------------------------------------------------------------------------------------------", color_red);
err = true;
}
}
else if(al_1_term_with_var_s == al_1_equation[2])
{
if(add_found != -1)
{
stringstream stupid_37(al_1_equation[0]);
long double mx_add_term1;
stupid_37 >> mx_add_term1;
stringstream stupid_38(al_1_equation[4]);
long double mx_add_term2;
stupid_38 >> mx_add_term2;
long double mx_inversed_pre_solution_add1 = mx_add_term2 - mx_add_term1;
al_1_solution = mx_inversed_pre_solution_add1 / al_1_num_before_var_int;
}
else if(minus_found != -1)
{
stringstream stupid_39(al_1_equation[0]);
long double mx_minus_term1;
stupid_39 >> mx_minus_term1;
stringstream stupid_40(al_1_equation[4]);
long double mx_minus_term2;
stupid_40 >> mx_minus_term2;
long double mx_inversed_pre_solution_minus1 = mx_minus_term2 + mx_minus_term1;
al_1_solution = mx_inversed_pre_solution_minus1 / al_1_num_before_var_int;
}
else if(times_found != -1)
{
stringstream stupid_41(al_1_equation[0]);
long double mx_times_term1;
stupid_41 >> mx_times_term1;
stringstream stupid_42(al_1_equation[4]);
long double mx_times_term2;
stupid_42 >> mx_times_term2;
long double mx_inversed_pre_solution_times1 = mx_times_term2 / mx_times_term1;
al_1_solution = mx_inversed_pre_solution_times1 / al_1_num_before_var_int;
}
else if(divide_found != -1)
{
stringstream stupid_43(al_1_equation[0]);
long double mx_divide_term1;
stupid_43 >> mx_divide_term1;
stringstream stupid_44(al_1_equation[4]);
long double mx_divide_term2;
stupid_44 >> mx_divide_term2;
long double mx_inversed_pre_solution_divide1 = mx_divide_term2 * mx_divide_term1;
al_1_solution = mx_inversed_pre_solution_divide1 / al_1_num_before_var_int;
}
else
{
print_text("------------------------------------------------------------------------------------------------------", color_red);
print_text("Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.", color_red);
print_text("------------------------------------------------------------------------------------------------------", color_red);
err = true;
}
}
else if(al_1_term_with_var_s == al_1_equation[4])
{
if(add_found != -1)
{
stringstream stupid_45(al_1_equation[0]);
long double mx_add_term1_;
stupid_45 >> mx_add_term1_;
stringstream stupid_46(al_1_equation[2]);
long double mx_add_term2_;
stupid_46 >> mx_add_term2_;
long double mx_inversed_pre_solution_add2 = mx_add_term2_ - mx_add_term1_;
al_1_solution = mx_inversed_pre_solution_add2 / al_1_num_before_var_int;
}
else if(minus_found != -1)
{
stringstream stupid_47(al_1_equation[0]);
long double mx_minus_term1_;
stupid_47 >> mx_minus_term1_;
stringstream stupid_48(al_1_equation[2]);
long double mx_minus_term2_;
stupid_48 >> mx_minus_term2_;
long double mx_inversed_pre_solution_minus2 = mx_minus_term2_ + mx_minus_term1_;
al_1_solution = mx_inversed_pre_solution_minus2 / al_1_num_before_var_int;
}
else if(times_found != -1)
{
stringstream stupid_49(al_1_equation[0]);
long double mx_times_term1_;
stupid_49 >> mx_times_term1_;
stringstream stupid_50(al_1_equation[2]);
long double mx_times_term2_;
stupid_50 >> mx_times_term2_;
long double mx_inversed_pre_solution_times2 = mx_times_term2_ / mx_times_term1_;
al_1_solution = mx_inversed_pre_solution_times2 / al_1_num_before_var_int;
}
else if(divide_found != -1)
{
stringstream stupid_51(al_1_equation[0]);
long double mx_divide_term1_;
stupid_51 >> mx_divide_term1_;
stringstream stupid_52(al_1_equation[2]);
long double mx_divide_term2_;
stupid_52 >> mx_divide_term2_;
long double mx_inversed_pre_solution_divide2 = mx_divide_term2_ * mx_divide_term1_;
al_1_solution = mx_inversed_pre_solution_divide2 / al_1_num_before_var_int;
}
else
{
print_text("------------------------------------------------------------------------------------------------------", color_red);
print_text("Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.", color_red);
print_text("------------------------------------------------------------------------------------------------------", color_red);
err = true;
}
}
else
{
print_text("-----------", color_red);
print_text("Error: B302", color_red);
print_text("-----------", color_red);
err = true;
}
}
else
{
print_text("-------------------------------------------------------------------------------------------------------------", color_red);
print_text("This calculator is still in beta testing cannot calculate that type of equation. Please try another equation.", color_dark_red);
print_text("-------------------------------------------------------------------------------------------------------------", color_red);
err = true;
algebra_1();
}
}
else if(al_1_char_before_var == -1)
{
int add_found = al_1_equation[1].find("+");
int minus_found = al_1_equation[1].find("-");
int times_found = al_1_equation[1].find("*");
int divide_found = al_1_equation[1].find("/");
long double al_1_solution = 0;
if(al_1_var_array_pos_int == 0)
{
if(add_found != -1)
{
stringstream stupid_13(al_1_equation[2]);
long double add_term1;
stupid_13 >> add_term1;
stringstream stupid_14(al_1_equation[4]);
long double add_term2;
stupid_14 >> add_term2;
al_1_solution = add_term2 + add_term1;
}
else if(minus_found != -1)
{
stringstream stupid_15(al_1_equation[2]);
long double minus_term1;
stupid_15 >> minus_term1;
stringstream stupid_16(al_1_equation[4]);
long double minus_term2;
stupid_16 >> minus_term2;
al_1_solution = minus_term1 - minus_term2;
}
else if(times_found != -1)
{
stringstream stupid_17(al_1_equation[2]);
long double times_term1;
stupid_17 >> times_term1;
stringstream stupid_18(al_1_equation[4]);
long double times_term2;
stupid_18 >> times_term2;
al_1_solution = times_term2 * times_term1;
}
else if(divide_found != -1)
{
stringstream stupid_19(al_1_equation[2]);
long double divide_term1;
stupid_19 >> divide_term1;
stringstream stupid_20(al_1_equation[4]);
long double divide_term2;
stupid_20 >> divide_term2;
al_1_solution = divide_term1 / divide_term2;
}
else
{
print_text("------------------------------------------------------------------------------------------------------", color_red);
print_text("Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.", color_red);
print_text("------------------------------------------------------------------------------------------------------", color_red);
err = true;
}
}
else if(al_1_var_array_pos_int == 2)
{
if(add_found != -1)
{
stringstream stupid_21(al_1_equation[0]);
long double add_term_1;
stupid_21 >> add_term_1;
stringstream stupid_22(al_1_equation[4]);
long double add_term_2;
stupid_22 >> add_term_2;
al_1_solution = add_term_2 - add_term_1;
}
else if(minus_found != -1)
{
stringstream stupid_23(al_1_equation[0]);
long double minus_term_1;
stupid_23 >> minus_term_1;
stringstream stupid_24(al_1_equation[4]);
long double minus_term_2;
stupid_24 >> minus_term_2;
al_1_solution = minus_term_2 + minus_term_1;
}
else if(times_found != -1)
{
stringstream stupid_25(al_1_equation[0]);
long double times_term_1;
stupid_25 >> times_term_1;
stringstream stupid_26(al_1_equation[4]);
long double times_term_2;
stupid_26 >> times_term_2;
al_1_solution = times_term_2 / times_term_1;
}
else if(divide_found != -1)
{
stringstream stupid_27(al_1_equation[0]);
long double divide_term_1;
stupid_27 >> divide_term_1;
stringstream stupid_28(al_1_equation[4]);
long double divide_term_2;
stupid_28 >> divide_term_2;
al_1_solution = divide_term_2 * divide_term_1;
}
else
{
print_text("------------------------------------------------------------------------------------------------------", color_red);
print_text("Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.", color_red);
print_text("------------------------------------------------------------------------------------------------------", color_red);
err = true;
}
}
else
{
if(add_found != -1)
{
stringstream stupid_61(al_1_equation[0]);
long double add_term_1;
stupid_61 >> add_term_1;
stringstream stupid_62(al_1_equation[2]);
long double add_term_2;
stupid_62 >> add_term_2;
al_1_solution = add_term_1 + add_term_2;
}
else if(minus_found != -1)
{
stringstream stupid_63(al_1_equation[0]);
long double minus_term_1;
stupid_63 >> minus_term_1;
stringstream stupid_64(al_1_equation[2]);
long double minus_term_2;
stupid_64 >> minus_term_2;
al_1_solution = minus_term_1 - minus_term_2;
}
else if(times_found != -1)
{
stringstream stupid_65(al_1_equation[0]);
long double times_term_1;
stupid_65 >> times_term_1;
stringstream stupid_66(al_1_equation[2]);
long double times_term_2;
stupid_66 >> times_term_2;
al_1_solution = times_term_1 * times_term_2;
}
else if(divide_found != -1)
{
stringstream stupid_67(al_1_equation[0]);
long double divide_term_1;
stupid_67 >> divide_term_1;
stringstream stupid_68(al_1_equation[2]);
long double divide_term_2;
stupid_68 >> divide_term_2;
al_1_solution = divide_term_1 / divide_term_2;
}
}
}
}
else if(al_1_var_times == 2)
{
string al_1_var1_arrterm = posc(al_1_equation, al_1_variable, 5, 0);
stringstream stupid_53(al_1_var1_arrterm);
int al_1_var1_arrterm_int;
stupid_53 >> al_1_var1_arrterm_int;
string al_1_var1_term = al_1_equation[al_1_var1_arrterm_int];
if(al_1_var1_arrterm_int == 0)
{
int i = 2;
do
{
int loopsake_find = al_1_equation[i].find(al_1_variable);
if(loopsake_find != -1) break;
else
i = i + 1;
}
while(i > 5);
int al_1_var2_arrterm_int = i;
string al_1_var2_term = al_1_equation[al_1_var2_arrterm_int];
string al_1_equals_pos = posc(al_1_equation, "=", 5, 0);
if(al_1_equals_pos == "3")
{
//hello u are probably lost by now if u are reading this b/c i stopped making comments b/c they were tedious
string al_1_char_before_var1;
string al_1_char_before_var2;
if(al_1_var2_arrterm_int == 2)
{
//if var positions are 0th and 2nd
if(al_1_var1_term.find(al_1_variable) != 0)
{
al_1_char_before_var1 = al_1_var1_term.erase(al_1_var1_term.size() - 1);
}
else if(al_1_var1_term.find(al_1_variable) == 0)
{
al_1_char_before_var1 = " ";
}
else
{
print_text("-----------", color_red);
print_text("Error: V1NF", color_red);
print_text("-----------", color_red);
err = true;
}
if(al_1_var2_term.find(al_1_variable) != 0)
{
al_1_char_before_var2 = al_1_var2_term.erase(al_1_var2_term.size() - 1);
}
else if(al_1_var2_term.find(al_1_variable) == 0)
{
al_1_char_before_var2 = " ";
}
else
{
print_text("-----------", color_red);
print_text("Error: V2NF", color_red);
print_text("-----------", color_red);
err = true;
}
//now to actually solve after variable configuration
int al_1_step_one;
int add_found = al_1_equation[1].find("+");
int minus_found = al_1_equation[1].find("-");
int times_found = al_1_equation[1].find("*");
int divide_found = al_1_equation[1].find("/");
long double al_1_char_before_var1_int;
long double al_1_char_before_var2_int;
if(al_1_char_before_var1 == " " || al_1_char_before_var2 == " ")
{
if(al_1_char_before_var1 == " ") al_1_char_before_var1_int = 1;
else;
if(al_1_char_before_var2 == " ") al_1_char_before_var2_int = 1;
else;
}
else
{
stringstream stupid_54(al_1_char_before_var1);
stupid_54 >> al_1_char_before_var1_int;
stringstream stupid_55(al_1_char_before_var2);
stupid_55 >> al_1_char_before_var2_int;
}
if(add_found != -1)
{
stringstream stupid_56(al_1_equation[4]);
long double mx_sumnation;
stupid_56 >> mx_sumnation;
al_1_step_one = al_1_char_before_var1_int + al_1_char_before_var2_int;
al_1_solution = mx_sumnation / al_1_step_one;
}
else if(minus_found != -1)
{
stringstream stupid_57(al_1_equation[4]);
long double mx_minuation;
stupid_57 >> mx_minuation;
al_1_step_one = al_1_char_before_var1_int - al_1_char_before_var2_int;
al_1_solution = mx_minuation / al_1_step_one;
}
else if(times_found != -1)
{
stringstream stupid_58(al_1_equation[4]);
long double mx_timenation;
stupid_58 >> mx_timenation;
al_1_step_one = al_1_char_before_var1_int * al_1_char_before_var2_int;
al_1_solution = mx_timenation / al_1_step_one;
}
else if(divide_found != -1)
{
stringstream stupid_59(al_1_equation[4]);
long double mx_divination;
stupid_59 >> mx_divination;
al_1_step_one = al_1_char_before_var1_int / al_1_char_before_var2_int;
al_1_solution = mx_divination / al_1_step_one;
}
else
{
print_text("------------------------------------------------------------------------------------------------------", color_red);
print_text("Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.", color_red);
print_text("------------------------------------------------------------------------------------------------------", color_red);
err = true;
}
}
}
else
{
print_text("-------------------------------------------------------------------------------------------------------------", color_red);
print_text("This calculator is still in beta testing cannot calculate that type of equation. Please try another equation.", color_red);
print_text("-------------------------------------------------------------------------------------------------------------", color_red);
err = true;
algebra_1();
}
}
else if(al_1_var1_arrterm_int == 2)
{
}
else if(al_1_var1_arrterm_int == 4)
{
}
else
{
print_text("-----------", color_red);
print_text("Error: B303", color_red);
print_text("-----------", color_red);
err = true;
algebra_1();
}
}
else
{
print_text("----------------------------------------------------------------------------------", color_red);
print_text("Either you repeated your variable too many times or your variable input was wrong.", color_red);
print_text("Please try again.", color_red);
print_text("----------------------------------------------------------------------------------", color_red);
err = true;
algebra_1();
}
if(err == false)
{
stringstream stupid_60;
stupid_60 << al_1_solution;
string al_1_solution_str = stupid_60.str();
print_text("-------", color_blue);
print(al_1_variable, color_green, color_black);
print(" = ", color_green, color_black);
print_text(al_1_solution_str, color_green);
print_text("-------", color_blue);
}
else if(err == true)
{
algebra_1();
}
}
else if(al_1_eqorex == "expression" || al_1_eqorex == "2" || al_1_eqorex == "(2)")
{
print_text("-----------------------------------------", color_blue);
print_text("This is an algebraic expression simplifier.", color_blue);
print_text("How many terms do you wish to simplify?", color_blue);
print_text("-----------------------------------------", color_blue); print(">>> ", color_green, color_black);
int al_1_ex_termnum;
cin >> al_1_ex_termnum;
int temp_var = al_1_ex_termnum;
int number_terms_inputted = al_1_ex_termnum;
al_1_ex_termnum = (al_1_ex_termnum * 2) - 1;
string al_1_expression[al_1_ex_termnum];
if(al_1_ex_termnum <= 30);
else
{
print_text("---------------", color_blue);
print_text("Too many terms.", color_blue);
print_text("---------------", color_blue);
algebra_1();
}
print_text("-------------------------------------", color_blue);
print_text("Enter your terms separated by spaces.", color_blue);
print_text("-------------------------------------", color_blue); print(">>> ", color_green, color_black);
int i = 0;
do
{
cin >> al_1_expression[i];
i = i + 1;
}
while(i < al_1_ex_termnum);
print_text("----------------------------------------", color_blue);
print_text("What character represents your variable?", color_blue);
print_text("----------------------------------------", color_blue); print(">>> ", color_green, color_black);
string al_1_variable;
cin >> al_1_variable;
int num_of_vars = find_num_of_chars(al_1_expression, al_1_variable, al_1_ex_termnum);
int num_of_nums = temp_var - num_of_vars; temp_var = 0;
string var_terms[num_of_vars];
string term;
i = 0;
do
{
term = al_1_expression[i];
temp_var = term.find(al_1_variable);
if(temp_var != -1) var_terms[i] = term;
else;
i++;
}
while(i < al_1_ex_termnum);
i = 0;
temp_var = 0;
int add_times = find_num_of_chars(var_terms, "+", al_1_ex_termnum);
int minus_times = find_num_of_chars(var_terms, "-", al_1_ex_termnum);
int times_times = find_num_of_chars(var_terms, "*", al_1_ex_termnum);
int divide_times = find_num_of_chars(var_terms, "/", al_1_ex_termnum);
int add_found[15];
do
{
if(add_times == -1) break;
else;
if(i == 1 || i == 3 || i == 5 || i == 7 || i == 9 || i == 11 || i == 13 || i == 15 || i == 17 || i == 19 || i == 21 || i == 23 || i == 25 || i == 27 || i == 29)
{
term = al_1_expression[i];
temp_var = term.find("+");
if(temp_var != -1) add_found[i] = i;
else;
}
else;
if(temp_var != -1) cout << add_found[i] << "\n";
else;
i++;
}
while(i < number_terms_inputted);
}
else
{
print_text("--------------------------------------------------", color_blue);
print_text("Please enter a valid choice. (equation/expression)", color_red);
print_text("--------------------------------------------------", color_blue); algebra_1();
}
}
void algebra_2()
{
print_text("ERROR: NO INTREGRATION FOUND", color_red);
return;
}
void algebra_3()
{
print_text("ERROR: NO INTREGRATION FOUND", color_red);
return;
}
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <stdio.h>
#include <math.h>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::stringstream;
using std::getline;
int info()
{
string op;
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("(1) Main menu", color_green);
print_text("(2) detect_simple_operation details", color_blue);
print_text("(3) algebra details", color_light_blue);
print_text("(4) order_of_ops details", color_yellow);
print_text("(5) Quit", color_red);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red); print(">>> ", color_green, color_black);
cin >> op;
cin.ignore();
if(op == "1" || op == "(1)") return 0;
else if(op == "2" || op == "(2)")
{
print_text(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,", color_orange);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("Operation status: fully functional", color_green);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("``````````````````````````````````", color_orange);
info();
}
else if(op == "3" || op == "(3)")
{
print_text(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,", color_orange);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("Operation status: Partial functionality:", color_orange);
print_text("1_variable_algebra: 3 term equations supported as in example.", color_blue);
print_text("1_variable_algebra: expression simplifier not working.", color_red);
print_text("2&3_variable_algebra: equation solver & expression simplifier not working", color_red);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("``````````````````````````````````````````````````````", color_orange);
info();
}
else if(op == "4" || op == "(4)")
{
print_text(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,", color_orange);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("Operation status: Partial functionality:", color_yellow);
print_text("2, 3 & 4 term simplification working", color_green);
print_text("Maximum 15 term simplification.", color_magenta);
print_text("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", color_red);
print_text("````````````````````````````````````````", color_orange);
info();
}
else if(op == "5" || op == "(5)") return 1;
return -1;
}
void detector()
{
print_text("------------------------------------------------------------------------", color_red);
print_text("Enter your expression.(ex. 134 - 456, or 4 ^ 7, or 20 sq root, 5!, etc.)", color_blue);
print_text("------------------------------------------------------------------------", color_red); print(">>> ", color_green, color_black);
string equation[3]; int i = 0; string equation_term_1;
cin >> equation[0];
equation_term_1 = equation[0];
do
{
if(equation_term_1.find("!") != -1)
{
break;
}
else;
cin >> equation[i + 1];
i = i + 1;
}
while(i < 2);
bool check1 = numbers_only(equation[0], true); bool check2 = numbers_only(equation[2], true);
if(check1 == false || check2 == false)
{
print_text("ERROR: an unrecognized character was detected.", color_dark_red);
return;
}
int add_found = equation[1].find("+");
int minus_found = equation[1].find("-");
int times_found = equation[1].find("*");
int divide_found = equation[1].find("/");
int power_found = equation[1].find("^");
int sqrt_found = equation[1].find("sq");
int fact_found = equation[0].find("!");
if(add_found != -1)
{
stringstream stupid_2(equation[0]);
long double add_term1_int;
stupid_2 >> add_term1_int;
stringstream stupid_3(equation[2]);
long double add_term2_int;
stupid_3 >> add_term2_int;
long double sum = add_term1_int + add_term2_int;
stringstream stupid_13;
stupid_13 << sum;
string sum_str = stupid_13.str();
print_text("------------------------", color_blue);
print(equation[0], color_green, color_black);
print(" plus ", color_green, color_black);
print(equation[2], color_green, color_black);
print(" equals ", color_green, color_black);
print_text(sum_str, color_green);
print_text("------------------------", color_blue);
}
else if(minus_found != -1)
{
stringstream stupid_4(equation[0]);
long double minus_term1_int;
stupid_4 >> minus_term1_int;
stringstream stupid_5(equation[2]);
long double minus_term2_int;
stupid_5 >> minus_term2_int;
long double difference = minus_term1_int - minus_term2_int;
stringstream stupid_14;
stupid_14 << difference;
string difference_str = stupid_14.str();
print_text("------------------------", color_blue);
print(equation[0], color_green, color_black);
print(" minus ", color_green, color_black);
print(equation[2], color_green, color_black);
print(" equals ", color_green, color_black);
print_text(difference_str, color_green);
print_text("------------------------", color_blue);
}
else if(times_found != -1)
{
stringstream stupid_6(equation[0]);
long double times_term1_int;
stupid_6 >> times_term1_int;
stringstream stupid_7(equation[2]);
long double times_term2_int;
stupid_7 >> times_term2_int;
long double product = times_term1_int * times_term2_int;
stringstream stupid_15;
stupid_15 << product;
string product_str = stupid_15.str();
print_text("-------------------------", color_blue);
print(equation[0], color_green, color_black);
print(" times ", color_green, color_black);
print(equation[2], color_green, color_black);
print(" equals ", color_green, color_black);
print_text(product_str, color_green);
print_text("-------------------------", color_blue);
}
else if(divide_found != -1)
{
stringstream stupid_8(equation[0]);
long double divide_term1_int;
stupid_8 >> divide_term1_int;
stringstream stupid_9(equation[2]);
long double divide_term2_int;
stupid_9 >> divide_term2_int;
long double quotient = divide_term1_int / divide_term2_int;
stringstream stupid_16;
stupid_16 << quotient;
string quotient_str = stupid_16.str();
print_text("----------------------------", color_blue);
print(equation[0], color_green, color_black);
print(" divided by ", color_green, color_black);
print(equation[2], color_green, color_black);
print(" equals ", color_green, color_black);
print_text(quotient_str, color_green);
print_text("----------------------------", color_blue);
}
else if(power_found != -1)
{
stringstream stupid_10(equation[0]);
long double base;
stupid_10 >> base;
stringstream stupid_11(equation[2]);
long double exponent;
stupid_11 >> exponent;
long double answer = pow(base, exponent);
stringstream stupid_17;
stupid_17 << answer;
string answer_str = stupid_17.str();
print_text("----------------------------", color_blue);
print(equation[0], color_green, color_black);
print(" to the ", color_green, color_black);
print(equation[2], color_green, color_black);
print(" power is ", color_green, color_black);
print_text(answer_str, color_green);
print_text("----------------------------", color_blue);
}
else if(sqrt_found != -1)
{
stringstream stupid_12(equation[0]);
long double sqwirt;
stupid_12 >> sqwirt;
long double sqwirt_ans = sqrt(sqwirt);
stringstream stupid_18;
stupid_18 << sqwirt_ans;
string sqwirt_ans_str = stupid_18.str();
print_text("--------------------------------", color_blue);
print("The square root of ", color_green, color_black);
print(equation[0], color_green, color_black);
print(" is ", color_green, color_black);
print_text(sqwirt_ans_str, color_green);
print_text("--------------------------------", color_blue);
}
else if(fact_found != -1)
{
stringstream calculator_50;
calculator_50 << equation[0];
string not_stupid_equation = calculator_50.str();
string fact_number = not_stupid_equation.erase(not_stupid_equation.size() - 1);
stringstream calculator_49(fact_number);
long double fact_number_int;
calculator_49 >> fact_number_int;
long double factorial = fact_number_int;
int i = factorial - 1;
long double factorial_done = factorial;
do
{
factorial = factorial * i;
i = i - 1;
}
while(i > 0);
stringstream stupid_19;
stupid_19 << factorial_done;
string factorial_done_str = stupid_19.str();
stringstream stupid_20;
stupid_20 << factorial;
string factorial_str = stupid_20.str();
print_text("-------------------------------", color_blue);
print("The factorial of ", color_green, color_black);
print(factorial_done_str, color_green, color_black);
print(" is ", color_green, color_black);
print_text(factorial_str, color_green);
print_text("-------------------------------", color_blue);
}
else
{
print_text("-----------------------------", color_red);
print_text("That is not a valid equation.", color_red);
print_text("-----------------------------", color_red);
}
}