Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Funciones{
- float x1 = 0;
- float x2 = 0;
- float tt1 = 0;
- float tt2 = 0;
- char operacion1;
- char operacion2;
- public:
- Funciones();
- void calcularYa(float x1, float x2, float tt1, float tt2, char operacion1, char operacion2);
- void calcularFinal(float x, float tt);
- void calcularDificil(float cp, char operacion1, float termino_ind, float termino_ind4, float cp2, char operacion2, float termino_ind2, float termino_ind3);
- void calcularDificilYa(float x1, float x2, float tt1, float tt2, char operacion1, char operacion2);
- void calcularDificilFinal(float x, float tt);
- };
- Funciones::Funciones(){
- }
- void Funciones::calcularDificil(float cp, char operacion1, float termino_ind, float termino_ind4, float cp2, char operacion2, float termino_ind2, float termino_ind3){
- //segundo paso
- cout << "Sexto paso" << endl;;
- cout << "(" << cp << "X " << operacion1 << " " << termino_ind << ")" << ". " << termino_ind4 << " = " << "(" << cp2 << "X " << operacion2 << " " << termino_ind2 << ")" << ". " << termino_ind3 << endl;
- float n_cp = termino_ind4 * cp;
- float n_ti = termino_ind4 * termino_ind;
- float n_cp2 = termino_ind3 * cp2;
- float n_ti2 = termino_ind3 * termino_ind2;
- cout << endl;
- cout << "Septimo paso" << endl;;
- if(n_ti < 0 and n_ti2 < 0){
- operacion1 = '-';
- operacion2 = '-';
- cout << n_cp << "X " << operacion1 << " " << n_ti << " = ";
- cout << n_cp2 << "X " << operacion2 << " " << n_ti2 << endl;
- cout << endl;
- cout << "Octavo paso" << endl;
- calcularDificilYa(n_cp, n_cp2, n_ti, n_ti2, operacion1, operacion2);
- }else if(n_ti < 0){
- operacion1 = '-';
- cout << n_cp << "X " << operacion1 << " " << n_ti << " = ";
- cout << n_cp2 << "X " << operacion2 << " " << n_ti2 << endl;
- cout << endl;
- cout << "Octavo paso" << endl;
- calcularDificilYa(n_cp, n_cp2, n_ti, n_ti2, operacion1, operacion2);
- }else if(n_ti2 < 0){
- operacion2 = '-';
- cout << n_cp << "X " << operacion1 << " " << n_ti << " = ";
- cout << n_cp2 << "X " << operacion2 << " " << n_ti2 << endl;
- cout << endl;
- cout << "Octavo paso" << endl;
- calcularDificilYa(n_cp, n_cp2, n_ti, n_ti2, operacion1, operacion2);
- }else{
- cout << n_cp << "X " << operacion1 << " " << n_ti << " = " << n_cp2 << "X " << operacion2 << " " << n_ti2 << endl;
- cout << endl;
- cout << "Octavo paso" << endl;
- calcularDificilYa(n_cp, n_cp2, n_ti, n_ti2, operacion1, operacion2);
- }
- }
- void Funciones::calcularDificilYa(float x1, float x2, float tt1, float tt2, char operacion1, char operacion2){
- if( operacion1 == '-' and operacion2 == '-'){
- operacion1= '+';
- operacion2= '+';
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 + tt1;
- float x = x1 + x2;
- cout << "Noveno paso" << endl;
- calcularDificilFinal(x, tt);
- }else if( operacion1 == '+' and operacion2 == '+'){
- //no hace falta verificar
- operacion1= '-';
- operacion2= '-';
- //en caso que todos sean positivos
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 - tt1;
- float x = x1 - x2;
- cout << "Noveno paso" << endl;
- calcularDificilFinal(x, tt);
- }else if(operacion2 == '-'){
- operacion1= '+';
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 - tt1;
- float x = x1 + x2;
- cout << "Noveno paso" << endl;
- calcularDificilFinal(x, tt);
- }else if(operacion1= '-'){
- operacion2= '+';
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 + tt1;
- float x = x1 - x2;
- cout << "Noveno paso" << endl;
- calcularDificilFinal(x, tt);
- }else{
- cout << "No ha ingresado nada" << endl;
- }
- }
- void Funciones::calcularDificilFinal(float x, float tt){
- cout << x << "X " << "= " << tt << endl;
- cout << endl;
- cout << "Decimo paso" << endl;
- cout << "X = " << tt << " / "<< x << endl;
- cout << endl;
- cout << "Resultado final" << endl;
- cout << "X = " << tt / x << endl;
- cout << " " << endl;
- }
- //**************************************
- void Funciones::calcularYa(float x1, float x2, float tt1, float tt2, char operacion1, char operacion2){
- if( operacion1 == '-' and operacion2 == '-'){
- operacion1= '+';
- operacion2= '+';
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 + tt1;
- float x = x1 + x2;
- cout << "Cuarto paso" << endl;
- calcularFinal(x, tt);
- }else if( operacion1 == '+' and operacion2 == '+'){
- //no hace falta verificar
- operacion1= '-';
- operacion2= '-';
- //en caso que todos sean positivos
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 - tt1;
- float x = x1 - x2;
- cout << "Cuarto paso" << endl;
- calcularFinal(x, tt);
- }else if(operacion2 == '-'){
- operacion1= '+';
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 - tt1;
- float x = x1 + x2;
- cout << "Cuarto paso" << endl;
- calcularFinal(x, tt);
- }else if(operacion1= '-'){
- operacion2= '+';
- cout << x1 << "X " << operacion1 << " " << x2 << "X = " << tt2 << " " << operacion2 << " " << tt1 << endl;
- cout << endl;
- float tt = tt2 + tt1;
- float x = x1 - x2;
- cout << "Cuarto paso" << endl;
- calcularFinal(x, tt);
- }else{
- cout << "No ha ingresado nada" << endl;
- }
- }
- void Funciones::calcularFinal(float x, float tt){
- cout << x << "X " << "= " << tt << endl;
- cout << endl;
- cout << "Quinto paso" << endl;
- cout << "X = " << tt << " / "<< x << endl;
- cout << endl;
- cout << "Resultado final" << endl;
- cout << "X = " << tt / x << endl;
- cout << " " << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement