#include <iostream>
#include <cmath>
#include <string>
using namespace std;

class MainProg
{
public:
    double temp_1;
    double temp_2;
    double temp_3;
    double c;
    double mass;
    double L;
    double Lambda;
    double q;
    int choose;
    int choose2;
    double Q_5;
    double Qq;
    double p;
    double V;
    double ml;
    string TextTodisplay;
    MainProg() :  ml(0), p(0), V(0), temp_1(0), temp_2(0), temp_3(0), c(0), mass(0), L(0), Lambda(0), choose(0), choose2(0), q(0), Q_5(0), Qq(0), TextTodisplay("") {}
    void welcome()
    {
        cout << "      ┏━┅┅┄┄⟞⟦✮⟧⟝┄┄┉┉━┓       " << endl;
        cout << "☆  Autor: Illiuoner | Herman   " << endl;
        cout << "☆            Vr: 1             " << endl;
        cout << "☆      Subject: Physics        " << endl;
        cout << "      ┗━┅┅┄┄⟞⟦✮⟧⟝┄┄┉┉━┛       " << endl;
        cout << " " << endl;
    }
    void MainNumQues()
    {
        cout << "┏━ ━━━━━━━━━━━━━━━━━━━━ ━┓                                                                    " << endl;
        cout << " 1.Calculate the amount of heat for a specific degree  (Q = c*m*(t2-t1))                      " << endl;
        cout << " 2.Calculate the amount of heat produced during fuel combustion (Q = q*m)                     " << endl;
        cout << " 3.Calculate the amount of heat required to melt a solid substance. (Q = λ*m)                 " << endl;
        cout << " 4.Calculate the amount of heat required for boiling (Q = L*m)                                " << endl;
        cout << " 5.Calculate |specific degree| + |melt| + |boiling| (Q = c*m*(t2-t1) + (Q = λ*m) + (Q = L*m)  " << endl;
        cout << " 6.Calculate the amount of heat released during solidification. (Q = -(λ*m))                  " << endl;
        cout << " 7.Calculate from ml to mass (m = p * v)                                                       " << endl;
        cout << " 0.Exit                                                                                       " << endl;
        cout << " DISCLAIMER! Write ONLY numbers: 1;2;3. Or 3,2. Do NOT write 2 * 10^5. Write: 200000          " << endl;
        cout << "┗━ ━━━━━━━━━━━━━━━━━━━━ ━┛                                                                    " << endl;

        cin >> choose;
        if (choose == 1)
        {
            CalculateSpecificDegree();
        }
        else if (choose == 2)
        {
            CalculateFuelCombustion();
        }
        else if (choose == 3)
        {
            CalculateMeltSolidSub();
        }
        else if (choose == 4)
        {
            CalculateHeatForBoil();
        }
        else if (choose == 5)
        {
            CalculateSpecificDegreeMeltBoil();
        }
        else if (choose == 6)
        {
            CalculateSolidification();
        }
        else if (choose == 7)
        {
            CalculateFromPtom();
        }
        else if (choose == 0)
        {
            return;
        }
        else
        {
            cout << "Error, try again" << endl;
            MainNumQues();
        }

    }
    void CalculateSpecificDegree()
    {
        cout << "Enter c (specific heat capacity(btw, water is 4200J/Kg*C)): \n";
        cin >> c;
        cout << "Enter m (mass | kg): \n";
        cin >> mass;
        cout << "Enter t1 (initial temperature (t1 < t2!!!)): \n";
        cin >> temp_1;
        cout << "Enter t2 (final temperature (t1 < t2!!!)):    \n";
        cin >> temp_2;
        double Q = c * mass * (temp_2 - temp_1);
        Qq = Q;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        MainNumQues();
    }
    void CalculateFuelCombustion()
    {
        cout << "Enter q(Specific heat of combustion J * Kg): \n";
        cin >> q;
        cout << "Enter m (mass | kg): \n";
        cin >> mass;
        double Q = q*mass;
        Qq = Q;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        MainNumQues();
    }
    void CalculateMeltSolidSub()
    {
        cout << "Enter λ (specific latent heat of fusion J * Kg)(btw, ice is 330000J*Kg): \n";
        cin >> Lambda;
        cout << "Enter m (mass | kg): \n";
        cin >> mass;
        double Q = Lambda * mass;
        Qq = Q;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        MainNumQues();
    }
    void CalculateHeatForBoil()
    {
        cout << "Enter L (specific latent heat of vaporization J * Kg)(btw, water is 2300000J*Kg): \n";
        cin >> L;
        cout << "Enter m (mass | kg): \n";
        cin >> mass;
        double Q = L * mass;
        Qq = Q;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        MainNumQues();
    }
    void CalculateSpecificDegreeMeltBoil()
    {
        cout << "Enter c (specific heat capacity(btw, water is 4200J/Kg*C)): \n";
        cin >> c;
        cout << "Enter m (mass | kg): \n";
        cin >> mass;
        cout << "Enter t1 (initial temperature (t1 < t2!!!)): \n";
        cin >> temp_1;
        cout << "Enter t2 (final temperature (t1 < t2!!!)):    \n";
        cin >> temp_2;
        double Q_1 = c * mass * (temp_2 - temp_1);
        Qq = Q_1;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        cout << "Now your substance will melt. Your substance temperature now is: " << temp_2 << "C" << endl;

        cout << "Enter λ (specific latent heat of fusion J * Kg)(btw, ice is 330000J*Kg): \n";
        cin >> Lambda;
        double Q_2 = Lambda * mass;
        Qq = Q_2;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        cout << "Now we need to increase your substance temperature for boiling. Your substance temperature now is: " << temp_2 << "C" << endl;

        cout << "Enter final temperature: \n";
        cin >> temp_3;
        double Q_3 = c * mass * (temp_3 - temp_2);
        Qq = Q_3;
        TextTodisplay = "Amount of heat (Q): ";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        cout << "Now your substance will boil. Your substance temperature now is: " << temp_3 << "C" << endl;
    
        cout << "Enter L (specific latent heat of vaporization J * Kg)(btw, water is 2300000J*Kg): \n";
        cin >> L;
        double Q_4 = L * mass;

        Q_5 = Q_1 + Q_2 + Q_3 + Q_4;

        Qq = Q_5;
        TextTodisplay = "Amount of heat (Q): ";
        system("cls");
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        
        
        MainNumQues();
    }
    void CalculateSolidification()
    {
        cout << "Enter λ (specific latent heat of fusion J * Kg)(btw, ice is 330000J*Kg): \n";
        cin >> Lambda;
        cout << "Enter m (mass | kg): \n";
        cin >> mass;
        double Q = (Lambda * mass);
        Qq = Q;
        TextTodisplay = "Amount of heat (Q): -";
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        numControl();
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        MainNumQues();
    }
    void CalculateFromPtom()
    {
        cout << "Enter p of your object: \n";
        cin >> p;
        cout << "Enter your ml of object: \n";
        cin >> ml;
        V = ml / 1000000;
        mass = p * V;
        
        cout << "┏━ ━━━━━━━━━✮━━━━━━━━━━━ ━┓   " << endl;
        cout << "Your mass is: " << mass << "kg\n";
        cout << "┗━ ━━━━━━━━━✮━━━━━━━━━━━ ━┛   " << endl;
        MainNumQues();
    }
    void numControl()
    {        
        if (Qq > 9999999999999999)
        {
            cout << "Error: too big number" << endl;
        }
        else if (Qq > 9999999999)
        {
            cout << TextTodisplay << Qq / 1000000 << " * 10^6 J" << endl;
        }
        else if (Qq > 999999)
        {
            cout << TextTodisplay << Qq / 10000 << " * 10^4 J" << endl;
        }
        else if (Qq < 0.0001)
        {
            cout << TextTodisplay << Qq * 10000 << " * 10^-4 J" << endl;
        }
        else if (Qq < 0.000000001)
        {
            cout << "Error: too small number"<< endl;
        }
        else 
        {
            cout << TextTodisplay << Qq << " J" << endl;
        };
    }

};

int main()
{
    MainProg m;
    m.welcome();
    m.MainNumQues();
    return 0;
}