online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <string> #include <cmath> #include <sstream> #include <stdio.h> #include <math.h> #include <functions.h> using std::cout; using std::cin; using std::endl; using std::string; using std::stringstream; using std::getline; int main() { cout << "________\n"; cout << "Welcome!\n" << "This is a calculator.\n" << "----------------------\n"; cout << "(1) detect_simple_operation\n(2) do_algebra\n(3) order_of_ops\n----------------------\n"; string op; cin >> op; 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 cout << "----------------------\n"; cout << "(1)1_variable\n(2)2_variable\n(3)3_variable\n"; cout << "----------------------\n"; string algebra_choice; cin >> algebra_choice; 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 { cout << "--------------------------------------\n"; cout << "Please enter a valid choice next time.\n"; cout << "--------------------------------------\n"; main(); } } else if(op == "3" || op == "(3)" || op == "order_of_ops") { cout << "--------------------------------------\n"; cout << "Welcome to this expression simplifier!\n"; cout << "--------------------------------------\n"; cout << "(1) algebraic_simplifier\n(2) reguar_order_of_ops\n"; cout << "------------------------\n"; cin >> op; if(op == "1" || op == "(1)" || op == "algebraic_simplifier") { cout << "----------------------\n"; cout << "(1)1_variable\n(2)2_variable\n(3)3_variable\n"; cout << "----------------------\n"; string algebra_choice; cin >> algebra_choice; 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 { cout << "--------------------------------------\n"; cout << "Please enter a valid choice next time.\n"; cout << "--------------------------------------\n"; main(); } } else if(op == "2" || op == "(2)" || op == "reguar_order_of_ops") { order_of_ops(); } } else { cout << "--------------------------------------------\n"; cout << "Please enter a valid operator and try again.\n"; cout << "--------------------------------------------\n"; main(); } cout << "-------------------------------\n"; cout << "Do you want to try again? (y/n)\n"; cout << "-------------------------------\n"; string choice; cin >> choice; if(choice == "y") { main(); } else if(choice == "n") { cout << "-------------------------------"; return 0; } else { cout << "--------------------------------------------\n"; cout << "Please enter a valid choice next time. (y/n)\n"; cout << "--------------------------------------------\n"; 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; void detector() { cout << "----------------------------------------------------------------------\n"; cout << "Enter your equation.(ex. 134 - 456, or 4 ^ 7, or 20 sq root, 5!, etc.)\n"; cout << "----------------------------------------------------------------------\n"; 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); 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; cout << "------------------------\n"; cout << add_term1_int << " plus " << add_term2_int << " equals " << sum << ".\n"; cout << "------------------------\n"; } 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; cout << "------------------------\n"; cout << minus_term1_int << " minus " << minus_term2_int << " equals " << difference << ".\n"; cout << "------------------------\n"; } 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; cout << "-------------------------\n"; cout << times_term1_int << " times " << times_term2_int << " equals " << product << ".\n"; cout << "-------------------------\n"; } 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; cout << "----------------------------\n"; cout << divide_term1_int << " divided by " << divide_term2_int << " equals " << quotient << ".\n"; cout << "----------------------------\n"; } 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); cout << "----------------------------\n"; cout << base << " to the " << exponent << " power is " << answer << ".\n"; cout << "----------------------------\n"; } else if(sqrt_found != -1) { stringstream stupid_12(equation[0]); long double sqwirt; stupid_12 >> sqwirt; long double sqwirt_ans = sqrt(sqwirt); cout << "--------------------------------\n"; cout << "The square root of " << sqwirt << " is " << sqwirt_ans << ".\n"; cout << "--------------------------------\n"; } 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); cout << "-------------------------------\n"; cout << "The factorial of " << factorial_done << " is " << factorial << ".\n"; cout << "-------------------------------\n"; } else { cout << "-----------------------------\n"; cout << "That is not a valid equation.\n"; cout << "-----------------------------\n"; } } 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"; } 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; } void algebra_1() { cout << "-----------------------\n"; cout << "(1)equation\n(2)expression\n"; cout << "-----------------------\n"; string al_1_eqorex; cin >> al_1_eqorex; if(al_1_eqorex == "equation" || al_1_eqorex == "1" || al_1_eqorex == "(1)") { cout << "-------------------------------------------------------\n"; cout << "Enter your equation like example. EX: x - 145 = 25.256 \n"; cout << "Please only use 3 term equations in the layout shown above.\n"; cout << "-------------------------------------------------------\n"; string al_1_equation[5]; for(int i = 0; i <= 4; i++) { cin >> al_1_equation[i]; } cout << "----------------------------------------\n"; cout << "What character represents your variable?\n"; cout << "----------------------------------------\n"; 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; } cout << "-----------------------------------------------------\n"; cout << "How many times is your variable used in the equation?\n"; cout << "-----------------------------------------------------\n"; int al_1_var_times; cin >> al_1_var_times; 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) { cout << "------------------------------------------\n"; cout << "Failed to find variable. Please try again.\n"; cout << "------------------------------------------\n"; 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); long double al_1_solution; 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } else { cout << "------------------------------------------------------------------------------------------------------\n"; cout << "Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.\n"; cout << "------------------------------------------------------------------------------------------------------\n"; } } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } else { cout << "------------------------------------------------------------------------------------------------------\n"; cout << "Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.\n"; cout << "------------------------------------------------------------------------------------------------------\n"; } } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } else { cout << "------------------------------------------------------------------------------------------------------\n"; cout << "Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.\n"; cout << "------------------------------------------------------------------------------------------------------\n"; } } else { cout << "-----------\n"; cout << "Error: B302\n"; cout << "-----------\n"; } } else { cout << "-------------------------------------------------------------------------------------------------------------\n"; cout << "This calculator is still in beta testing cannot calculate that type of equation. Please try another equation.\n"; cout << "-------------------------------------------------------------------------------------------------------------\n"; 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; 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } else { cout << "------------------------------------------------------------------------------------------------------\n"; cout << "Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.\n"; cout << "------------------------------------------------------------------------------------------------------\n"; } } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } else { cout << "------------------------------------------------------------------------------------------------------\n"; cout << "Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.\n"; cout << "------------------------------------------------------------------------------------------------------\n"; } } else { cout << "----------------------------\n"; cout << "Error: you are being stupid.\n"; cout << "----------------------------\n"; } } } 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 { cout << "-----------\n"; cout << "Error: V1NF\n"; cout << "-----------\n"; } 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 { cout << "-----------\n"; cout << "Error: V2NF\n"; cout << "-----------\n"; } //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("/"); int al_1_solution; 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } 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; cout << "--------\n"; cout << al_1_variable << " = " << al_1_solution << "\n"; cout << "--------\n"; } else { cout << "------------------------------------------------------------------------------------------------------\n"; cout << "Invalid equation. This calculator is still in beta testing so that equation may become avaliable soon.\n"; cout << "------------------------------------------------------------------------------------------------------\n"; } } } else { cout << "-------------------------------------------------------------------------------------------------------------\n"; cout << "This calculator is still in beta testing cannot calculate that type of equation. Please try another equation.\n"; cout << "-------------------------------------------------------------------------------------------------------------\n"; algebra_1(); } } else if(al_1_var1_arrterm_int == 2) { } else if(al_1_var1_arrterm_int == 4) { } else { cout << "-----------\n"; cout << "Error: B303\n"; cout << "-----------\n"; algebra_1(); } } else { cout << "---------------------------------------------------------------------------------\n"; cout << "Either you repeated your variable too many times or your variable input was wrong.\n Please try again\n"; cout << "---------------------------------------------------------------------------------\n"; algebra_1(); } } else if(al_1_eqorex == "expression" || al_1_eqorex == "2" || al_1_eqorex == "(2)") { cout << "---------------------------------------\n"; cout << "This is an expression simplifier.\nHow many terms do you wish to simplify?\n"; cout << "---------------------------------------\n"; 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 { cout << "---------------\n"; cout << "Too many terms.\n"; cout << "---------------\n"; algebra_1(); } cout << "-------------------------------------\n"; cout << "Enter your terms separated by spaces.\n"; cout << "-------------------------------------\n"; int i = 0; do { cin >> al_1_expression[i]; i = i + 1; } while(i < al_1_ex_termnum); cout << "----------------------------------------\n"; cout << "What character represents your variable?\n"; cout << "----------------------------------------\n"; 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 { cout << "--------------------------------------------------\n"; cout << "Please enter a valid choice. (equation/expression)\n"; cout << "--------------------------------------------------\n"; algebra_1(); } } void algebra_2() { } void algebra_3() { } void order_of_ops() { }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue