# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#define MAX 1000
using namespace std;

const time_t ctt = time(0);
int history(),q1(),q2(),q3(),q4(),q5(),q6(),q7(),menu();
void input(int mat1[][10], int mat2[][10], int row1, int col1, int row2, int col2);
void multiply(int mat1[][10], int mat2[][10], int mult[][10], int row1, int col1, int row2, int col2);
void addition(int mat1[][10], int mat2[][10], int mult[][10], int row1, int col1, int row2, int col2);
void subtract(int mat1[][10], int mat2[][10], int mult[][10], int row1, int col1, int row2, int col2);
void binary(int);
void circle(),rectangle();
void calculation(float,float,float);

int history()
{
    system("cls");
    ifstream in("history.txt");

  if(!in) {
    cout << "Cannot open input file."<<endl;
    return 1;
  }

  char str[255];

  while(in) {
    in.getline(str, 255);
    if(in) cout << str << endl;
  }
  in.close();
}

int main()
{
    int choice;
    do
    {
        cout<<"The Radiant Calculator"<<endl;
        cout<<endl;
        cout<<"(1)  Operations of scalar values"<<endl;
        cout<<"(2)  Matrices"<<endl;
        cout<<"(3)  Conversion between Binary, Hexadecimal and Decimal Values."<<endl;
        cout<<"(4)  Trigonometric."<<endl;
        cout<<"(5)  Electrical"<<endl;
        cout<<"(6)  Rectangles and Circles"<<endl;
        cout<<"(7)  Quadratic Equation"<<endl;
        cout<<"(8)  History"<<endl;
        cout<<"(9)  Exit"<<endl<<endl;
        cout<<"Enter Your Choice:"<<endl;
        cin>>choice;

        if(choice==8)
        {
            system("cls");
            history();
            system("pause");
            system("cls");
        }
        else if(choice==7)
        {
            system("cls");
            q7();
            system("pause");
            system("cls");
        }
        else if(choice==6)
        {
            system("cls");
            q6();
            system("cls");
        }
        else if(choice==5)
        {
            system("cls");
            q5();
            system("cls");
        }
        else if(choice==4)
        {
            system("cls");
            q4();
            system("cls");
        }
        else if(choice==3)
        {
            system("cls");
            q3();
            system("cls");
        }
        else if(choice==2)
        {
            system("cls");
            q2();
            system("cls");
        }
        else if(choice==1)
        {
            system("cls");
            q1();
            system("cls");
        }

    }
    while(choice != 9);
    system("cls");
    cout<<"Thank You For Using This Calculator"<<endl;
    system("exit");

}


int q7()
{
    float a, b, c;
    ofstream history;
    history.open ("history.txt",ofstream::app);

    cout<<"Roots Of Quadratic Equation"<<endl;
    cout<<endl;
    cout << "Enter coefficients a, b and c: "<<endl;
    cout <<"a: ";
    cin >> a;
    cout <<"b: ";
    cin >> b;
    cout <<"c: ";
    cin >> c;
    cout<<endl;

    history<<"**************************************************************"<<endl;
    history<<asctime(localtime(&ctt))<<endl;
    history<<"**************************************************************"<<endl;
    history<<"Roots Of Quadratic Equation"<<endl;
    history<<endl<<endl;
    history<< "Enter coefficients a, b and c: "<<endl;
    history<<"a: "<<endl;
    history<<a<<endl;
    history<<"b: "<<endl;
    history<<b<<endl;
    history<<"c: "<<endl;
    history<<c<<endl;
    history<<endl<<endl;

    calculation(a,b,c);
    history.close();
    return 0;
}
void calculation(float a,float b,float c)
{
    ofstream history;
    history.open ("history.txt",ofstream::app);
    float  x1, x2, determinant, realPart, imaginaryPart;
    determinant = b*b - 4*a*c;

    if (determinant > 0) {
        x1 = (-b + sqrt(determinant)) / (2*a);
        x2 = (-b - sqrt(determinant)) / (2*a);
        cout << "Roots are real and different." << endl;
        cout << "x1 = " << x1 << endl;
        cout << "x2 = " << x2 << endl;
        cout<<"\n";
        history<< "Roots are real and different." << endl;
        history<< "x1 = " << x1 << endl;
        history<< "x2 = " << x2 << endl;
        history<<"\n"<<endl;
        cout<<"The result will save into the file"<<endl;

    }

    else if (determinant == 0) {
        cout << "Roots are real and same." << endl;
        history<< "Roots are real and same." << endl;
        x1 = (-b + sqrt(determinant)) / (2*a);
        cout << "x1 = x2 =" << x1 << endl;
        cout<<"\n";
        history<< "x1 = x2 =" << x1 << endl;
        history<<"\n"<<endl;

        cout<<"The result will save into the file"<<endl;
    }

    else {
        realPart = -b/(2*a);
        imaginaryPart =sqrt(-determinant)/(2*a);
        cout << "Roots are complex and different."  << endl;
        cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
        cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;
        cout<<"\n";
        history<< "Roots are complex and different."  << endl;
        history<< "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
        history<< "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;
        history<<"\n"<<endl;

        cout<<"The result will save into the file"<<endl;
    }
}

struct rect
{
    float perimeter;
    float volume;
    float area;
    float length;
    float width;
    float height;
};

struct cir
{
    float radius;
    float area;
    float circum;
    float volume;
};
int q6()
{
    int choice;
    ofstream history;
    history.open ("history.txt",ofstream::app);

    history<<"**************************************************************"<<endl;
    history<<asctime(localtime(&ctt))<<endl;
    history<<"**************************************************************"<<endl;

    cout << fixed << showpoint << setprecision(2);
    while(choice != 3)
        {
            choice=menu();
         if(choice==1)
         {
            system("cls");
            circle();
            system("pause");
            system("cls");
         }
         if(choice==2)
         {
            system("cls");
            rectangle();
            system("pause");
            system("cls");
         }
         else
         {
            cout<<endl;
            cout<<"You enter invalid number"<<endl;
            cout<<endl;

         }}
    system("cls");
    cout<<"The result will save into the file"<<endl;
    cout<<endl;
    history.close();
    return 0;
}
int menu()
{
    int choice;
    cout<<"Please choose the shape"<<endl;
    cout<<endl;
    cout<<"(1) Circle"<<endl;
    cout<<"(2) Rectangle"<<endl;
    cout<<"(3) Exit"<<endl;
    cout<<endl;
    cout << "Please choose: ";
    cin >> choice;
    return choice;
}
void circle()
{
    ofstream history;
    history.open ("history.txt",ofstream::app);
    const float PI=3.14159;
	cir lame;
	cout << "It will calculate the Circumference,Area and Volume of Circle"<<endl;
	cout <<endl;
	cout <<"Enter radius of circle: ";
	cin >>lame.radius;

	history<<"It will calculate the Circumference,Area and Volume of Circle"<<endl;
	history<<endl<<endl;
	history<<"Enter radius of circle: "<<endl;
	history<<lame.radius<<endl;

	lame.area=PI*lame.radius*lame.radius;
	lame.circum=2*PI*lame.radius;
	lame.volume=(4/3)*PI*lame.radius*lame.radius*lame.radius;

	cout<<endl;
	cout <<"Circumference of circle: "<<lame.circum<<endl;
	cout <<"Area of circle: "<<lame.area<<endl;
	cout <<"Volume of Sphere: "<<lame.volume<<endl;
	cout<<endl;

	history<<endl<<endl;
	history<<"Circumference of circle: "<<lame.circum<<endl;
	history<<"Area of circle: "<<lame.area<<endl;
	history<<"Volume of Sphere: "<<lame.volume<<endl;
	history<<endl<<endl;

}
void rectangle()
{
    ofstream history;
    history.open ("history.txt",ofstream::app);

    struct rect lame2;

    cout << "This will calculate the value of Perimeter, Area and Volume Of Rectangle\n\n";
    cout<<"Enter Width of Rectangle = ";
    cin>>lame2.width;
    cout<<"Enter Height of Rectangle = ";
    cin>>lame2.height;
    cout<<"Enter length of Rectangle = ";
    cin >>lame2.length;

    history<< "This will calculate the value of Perimeter, Area and Volume Of Rectangle\n\n";
    history<<"Enter Width of Rectangle = "<<endl;
    history<<lame2.width<<endl;
    history<<"Enter Height of Rectangle = "<<endl;
    history<<lame2.height<<endl;
    history<<"Enter length of Rectangle = "<<endl;
    history<<lame2.length<<endl;

    lame2.area = lame2.height*lame2.width;
    lame2.perimeter = 2*(lame2.height+lame2.width);
    lame2.volume = lame2.height*lame2.length*lame2.width;

    cout<<endl;
    cout<<"Perimeter of Rectangle are = "<<lame2.perimeter<<endl;
    cout<<"Area of Rectangle = "<<lame2.area<<endl;
    cout<<"Volume of Rectangle are = "<<lame2.volume<<endl;
    cout<<endl;

    history<<endl<<endl;
    history<<"Perimeter of Rectangle are = "<<lame2.perimeter<<endl;
    history<<"Area of Rectangle = "<<lame2.area<<endl;
    history<<"Volume of Rectangle are = "<<lame2.volume<<endl;
    history<<endl<<endl;

}
int q5()
{
    ofstream history;
    history.open("history.txt",fstream::app);
    history<<"**************************************************************"<<endl;
    history<<asctime(localtime(&ctt))<<endl;
    history<<"**************************************************************"<<endl;

    int Choice;
    float p,q,r,v,i,t,n,a,a1,a2,c,d,e;
    int choice, yes;

        cout<< "Please choose your desired electrical quantity:"<<endl;
        cout<<endl;
        cout<<"(1) Electrical Charge (Q)"<<endl;
        cout<<"(2) Capacitance (C)"<<endl;
        cout<<"(3) Current (I)"<<endl;
        cout<<"(4) Voltages (V)"<<endl;
        cout<<"(5) Power (P)"<<endl;
        cout<<"(6) Exit"<<endl;
        cout<<endl;
        cout << "Your choice: ";
        cin >> Choice;
        system("cls");

        switch (Choice)
        {
            case 1:
            {
                cout <<"Choose your desired formula (unit: Coulomb): "<<endl;
                cout <<endl;
                cout <<"(1) Q = C x V"<<endl;
                cout <<"(2) Q = I x t"<<endl;
                cout <<"(3) Q = n x e"<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> choice;

                history << "Choose your desired formula (unit: Coulomb): "<<endl;
                history <<endl<<endl;
                history <<"(1) Q = C x V"<<endl;
                history <<"(2) Q = I x t"<<endl;
                history <<"(3) Q = n x e"<<endl;
                history << "Your choice : ";
                history <<endl<<endl;
                history << choice;
                system("cls");

                switch(choice)
                {
                    case 1:
                        {
                            cout << "Enter the value for Capacitance,C (unit: Farad): ";
                            cin >> c;
                            cout <<endl;
                            cout << "Enter the value for Voltage,V (unit: Volt): ";
                            cin >> v;
                            cout <<endl;
                            cout << "The answer is "<< (q=c*v) << "C";
                            history << "Enter the value for Capacitance,C (unit: Farad): ";
                            history << c;
                            history <<endl<<endl;
                            history << "Enter the value for Voltage,V (unit: Volt): ";
                            history << v;
                            history <<endl<<endl;
                            history << "The answer is "<< (q=c*v) << "C";
                        }
                        break;
                    case 2:
                        {
                            cout << "Enter the value for Current,I (unit: Ampere): ";
                            cin >> i;
                            cout <<endl;
                            cout << "Enter the value for time,t (unit: seconds): ";
                            cin >> t;
                            cout <<endl;
                            cout << "The answer is "<< (q=i*t) << "C";
                            history << "Enter the value for Current,I (unit: Ampere): ";
                            history << i;
                            history <<endl<<endl;
                            history << "Enter the value for time,t (unit: seconds): ";
                            history << t;
                            history <<endl<<endl;
                            history << "The answer is "<< (q=i*t) << "C";
                        }
                        break;
                    case 3:
                        {
                            cout << "Enter the value for number of electrons/protons,n: ";
                            cin >> n;
                            e = 1.6*pow(10,-19);
                            cout <<endl;
                            cout << "The answer is "<< (q=n*e) << "C";
                            history << "Enter the value for number of electrons/protons,n: ";
                            history << n;
                            history <<endl<<endl;
                            history << "The answer is "<< (q=n*e) << "C";
                        }
                        break;
                    }
                cout <<endl;
                cout <<endl;
                cout <<"Do you wish to continue with another operation?"<<endl;
                cout <<"(1) Yes"<<endl;
                cout <<"(2) No"<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> yes;
                system("cls");

                if(yes == 1){
                        q5();
                }
                else{
                        cout<<"Thank you!"<<endl;
                        cout << "The numbers were saved to a file."<<endl;
                        history << "The numbers were saved to a file."<<endl;
                        cout << "Done."<<endl;
                        history << "Done."<<endl;
                        history.close();
                }
            }
            break;

            case 2:
            {

                cout <<"Choose your desired formula (unit: Farad): "<<endl;
                cout <<endl;
                cout <<"(1) C = (p x A)/D"<<endl;
                cout <<"(2) C = Q/V"<<endl;
                cout <<"NOTE: p is permittivity of dielectric."<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> choice;

                history <<"Choose your desired formula (unit: Farad): "<<endl;
                history <<endl<<endl;
                history <<"(1) C = (p x A)/D"<<endl;
                history <<"(2) C = Q/V"<<endl;
                history <<"NOTE: p is permittivity of dielectric."<<endl;
                history <<endl<<endl;
                history << "Your choice : ";
                history << choice;
                system("cls");

                switch(choice)
                {
                    case 1:
                        {
                            cout << "Enter the value for the length and the width for the area of one plate,A (unit: meters^2): ";
                            cin >> a1 >> a2;
                            a = a1*a2;
                            p = 8.84*pow(10,-12);
                            cout <<endl;
                            cout << "Enter the distance between plates,D (unit: meters): ";
                            cin >> d;
                            cout <<endl;
                            cout << "The answer is "<< ((p*a)/d) << "F";

                            history << "Enter the value for the length and the width for the area of one plate,A (unit: meters^2): ";
                            history << a1 << a2;
                            history <<endl<<endl;
                            history << "Enter the distance between plates,D (unit: meters): ";
                            history << d;
                            history <<endl<<endl;
                            history << "The answer is "<< ((p*a)/d) << "F";
                        }
                        break;

                    case 2:
                        {
                            cout << "Enter the value for Electrical Charge,Q (unit: Coulomb): ";
                            cin >> q;
                            cout <<endl;
                            cout << "Enter the value for Voltage, V (unit: Volt): ";
                            cin >> v;
                            cout <<endl;
                            cout << "The answer is " << (c=(q/v)) << "F";

                            history << "Enter the value for Electrical Charge,Q (unit: Coulomb): ";
                            history << q;
                            history <<endl<<endl;
                            history << "Enter the value for Voltage, V (unit: Volt): ";
                            history << v;
                            history <<endl<<endl;
                            history << "The answer is " << (c=(q/v)) << "F";
                        }
                        break;
                    }
                cout <<endl;
                cout <<endl;
                cout <<"Do you wish to continue with another operation?"<<endl;
                cout <<"(1) Yes"<<endl;
                cout <<"(2) No"<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> yes;
                system("cls");

                if(yes == 1){
                        q5();
                }
                else{
                        cout<<"Thank you!"<<endl;
                        cout << "The numbers were saved to a file."<<endl;
                        history << "The numbers were saved to a file."<<endl;
                        cout << "Done."<<endl;
                        history << "Done."<<endl;
                        history.close();
                }
            }
            break;

            case 3:
            {

                cout <<"Choose your desired formula (unit: Ampere): "<<endl;
                cout <<endl;
                cout <<"(1) I = (P/R)^(1/2)"<<endl;
                cout <<"(2) I = P/V"<<endl;
                cout <<"(3) I = V/R"<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> choice;

                history<<"Choose your desired formula (unit: Ampere): "<<endl;
                history <<endl <<endl;
                history <<"(1) I = (P/R)^(1/2)"<<endl;
                history<<"(2) I = P/V"<<endl;
                history<<"(3) I = V/R"<<endl;
                history<<endl;
                history<< "Your choice : ";
                history<< choice;
                system("cls");

                switch(choice)
                {
                    case 1:
                        {
                            cout << "Enter the value for Power,P (unit: Watt): ";
                            cin >> p;
                            cout <<endl;
                            cout << "Enter the value for Resistance,R (unit: Ohm): ";
                            cin >> r;
                            cout <<endl;
                            cout << "The answer is "<< sqrt(p/r) << "A";

                            history << "Enter the value for Power,P (unit: Watt): ";
                            history << p;
                            history <<endl<<endl;
                            history << "Enter the value for Resistance,R (unit: Ohm): ";
                            history << r;
                            history <<endl<<endl;
                            history << "The answer is "<< sqrt(p/r) << "A";
                        }
                        break;
                    case 2:
                        {
                            cout << "Enter the value for Power,P (unit: Watt): ";
                            cin >> p;
                            cout <<endl;
                            cout << "Enter the value for Voltage,V (unit: Volt): ";
                            cin >> v;
                            cout <<endl;
                            cout << "The answer is "<< (i=p/v) << "A";

                            history << "Enter the value for Power,P (unit: Watt): ";
                            history << p;
                            history <<endl<<endl;
                            history << "Enter the value for Voltage,V (unit: Volt): ";
                            history << v;
                            history <<endl<<endl;
                            history << "The answer is "<< (i=p/v) << "A";
                        }
                        break;

                    case 3:
                        {
                            cout << "Enter the value for Voltage,V (unit: Volt): ";
                            cin >> v;
                            cout <<endl;
                            cout << "Enter the value for Resistance,R (unit: Ohm): ";
                            cin >> r;
                            cout <<endl;
                            cout << "The answer is "<< (i=v/r) << "A";

                            history << "Enter the value for Voltage,V (unit: Volt): ";
                            history << v;
                            history <<endl<<endl;
                            history << "Enter the value for Resistance,R (unit: Ohm): ";
                            history << r;
                            history <<endl<<endl;
                            history << "The answer is "<< (i=v/r) << "A";
                        }
                        break;
                    }
                    cout <<endl;
                    cout <<endl;
                    cout <<"Do you wish to continue with another operation?"<<endl;
                    cout <<"(1) Yes"<<endl;
                    cout <<"(2) No"<<endl;
                    cout <<endl;
                    cout << "Your choice : ";
                    cin >> yes;
                    system("cls");

                    if(yes == 1){
                            q5();
                    }
                    else{
                            cout<<"Thank you!"<<endl;
                            cout <<"The result will save into the file"<<endl;
                            history <<"The result will save into the file"<<endl;
                            cout << "Done."<<endl;
                            history << "Done."<<endl;
                            history.close();
                        }
            }
            break;

            case 4:
            {
                cout << "Choose your desired formula (unit: Volt): "<<endl;
                cout <<endl;
                cout <<"(1) V = I x R"<<endl;
                cout <<"(2) V = P/I"<<endl;
                cout <<"(3) V = (P x R)^(1/2)"<<endl;
                cout <<endl;
                cout <<"Your choice : ";
                cin >> choice;

                history << "Choose your desired formula (unit: Volt): "<<endl;
                history<<endl<<endl;
                history<<"(1) V = I x R"<<endl;
                history<<"(2) V = P/I"<<endl;
                history<<"(3) V = (P x R)^(1/2)"<<endl;
                history<<endl<<endl;
                history << "Your choice : ";
                history << choice;
                system("cls");

                switch(choice)
                {
                    case 1:
                        {
                            cout << "Enter the value for Current,I (unit: Ampere): ";
                            cin >> i;
                            cout <<endl;
                            cout << "Enter the value for Resistance,R (unit: Ohm): ";
                            cin >> r;
                            cout <<endl;
                            cout << "The answer is "<< (v=i*r) << "V";

                            history << "Enter the value for Current,I (unit: Ampere): ";
                            history << i;
                            history <<endl<<endl;
                            history << "Enter the value for Resistance,R (unit: Ohm): ";
                            history << r;
                            history <<endl<<endl;
                            history << "The answer is "<< (v=i*r) << "V";
                        }
                        break;
                    case 2:
                        {
                            cout << "Enter the value for Power,P (unit: Watt): ";
                            cin >> p;
                            cout <<endl;
                            cout << "Enter the value for Current,I (unit: Ampere): ";
                            cin >> i;
                            cout <<endl;
                            cout << "The answer is "<< (v=p/i) << "V";

                            history << "Enter the value for Power,P (unit: Watt): ";
                            history << p;
                            history <<endl<<endl;
                            history << "Enter the value for Current,I (unit: Ampere): ";
                            history << i;
                            history <<endl<<endl;
                            history << "The answer is "<< (v=p/i) << "V";
                        }
                        break;
                    case 3:
                        {
                            cout << "Enter the value for Power,P (unit: Watt): ";
                            cin >> p;
                            cout <<endl;
                            cout << "Enter the value for Resistance,R (unit: Ohm): ";
                            cin >> r;
                            cout <<endl;
                            cout << "The answer is "<< sqrt(p*r) << "V";

                            history << "Enter the value for Power,P (unit: Watt): ";
                            history << p;
                            history <<endl<<endl;
                            history << "Enter the value for Resistance,R (unit: Ohm): ";
                            history << r;
                            history <<endl<<endl;
                            history << "The answer is "<< sqrt(p*r) << "V";
                        }
                        break;
                    }
                cout <<endl;
                cout <<endl;
                cout <<"Do you wish to continue with another operation?"<<endl;
                cout <<"(1) Yes"<<endl;
                cout <<"(2) No"<<endl;
                cout <<endl;
                cout <<"Your choice : ";
                cin >> yes;
                system("cls");

                if(yes == 1){
                        q5();
                }
                else{
                        cout<<"Thank you!"<<endl;
                        cout <<"The result will save into the file"<<endl;
                        history <<"The result will save into the file"<<endl;
                        cout << "Done."<<endl;
                        history << "Done."<<endl;
                        history.close();
                    }
            }

            case 5:
            {

                cout << "Choose your desired formula (unit: Watt): "<<endl;
                cout <<endl;
                cout <<"(1) P = (V^2)/R"<<endl;
                cout <<"(2) P = I x V"<<endl;
                cout <<"(3) P = (I^2) x R"<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> choice;

                history << "Choose your desired formula (unit: Watt): "<<endl;
                history<<endl<<endl;
                history<<"(1) P = (V^2)/R"<<endl;
                history<<"(2) P = I x V"<<endl;
                history<<"(3) P = (I^2) x R"<<endl;
                history<<endl<<endl;
                history << "Your choice : ";
                history << choice;
                system("cls");

                switch(choice)
                {
                    case 1:
                        {
                            cout << "Enter the value for Voltage,V (unit: Volt): ";
                            cin >> v;
                            cout <<endl;
                            cout << "Enter the value for Resistance,R (unit: Ohm): ";
                            cin >> r;
                            cout <<endl;
                            cout << "The answer is "<< pow(v,2)/r << "W";

                            history << "Enter the value for Voltage,V (unit: Volt): ";
                            history << v;
                            history<<endl<<endl;
                            history << "Enter the value for Resistance,R (unit: Ohm): ";
                            history << r;
                            history<<endl<<endl;
                            history << "The answer is "<< pow(v,2)/r << "W";
                        }
                    break;
                    case 2:
                        {
                            cout << "Enter the value for Current,I (unit: Ampere): ";
                            cin >> i;
                            cout <<endl;
                            cout << "Enter the value for Voltage,V (unit: Volt): ";
                            cin >> v;
                            cout <<endl;
                            cout << "The answer is "<< (p=i*v) << "W";
                            history << "Enter the value for Current,I (unit: Ampere): ";
                            history << i;
                            history<<endl<<endl;
                            history << "Enter the value for Voltage,V (unit: Volt): ";
                            history << v;
                            history<<endl<<endl;
                            history << "The answer is "<< (p=i*v) << "W";
                        }
                    break;

                    case 3:
                        {
                            cout << "Enter the value for Current,I (unit: Ampere): ";
                            cin >> i;
                            cout <<endl;
                            cout << "Enter the value for Resistance,R (unit: Ohm): ";
                            cin >> r;
                            cout <<endl;
                            cout << "The answer is "<< pow(i,2)*r << "W";

                            history << "Enter the value for Current,I (unit: Ampere): ";
                            history << i;
                            history<<endl<<endl;
                            history << "Enter the value for Resistance,R (unit: Ohm): ";
                            history << r;
                            history<<endl<<endl;
                            history << "The answer is "<< pow(i,2)*r << "W";
                        }
                    break;
                    }
                cout <<endl;
                cout <<endl;
                cout << "Do you wish to continue with another operation?"<<endl;
                cout << "(1) Yes"<<endl;
                cout <<"(2) No"<<endl;
                cout <<endl;
                cout << "Your choice : ";
                cin >> yes;
                system("cls");

                if(yes == 1){
                        q5();
                }
                else{
                        cout<<"Thank you!"<<endl;
                        cout <<"The result will save into the file"<<endl;

                        history<<"The result will save into the file"<<endl;
                        cout << "Done."<<endl;
                        history<< "Done."<<endl;
                        history.close();
                    }
            }
            break;

            case 6:
            {
                cout<<"Thank you!"<<endl;
            }
            break;

        default: main();
        }
    }

    int q4()
{

	float result,x,radian,degrees;
    char conti;
    int c;
    ofstream history;
	history.open("history.txt",fstream::app);

do
{

    ofstream history;
    history.open("history.txt",fstream::app);
    cout<<"Trigonometric Operation"<<endl;
    cout<<endl;
    cout<<"(1) Cosine"<<endl;
    cout<<"(2) Sine"<<endl;
    cout<<"(3) Tangent"<<endl;
    cout<<"(4) Cotangent"<<endl;
    cout<<"(5) Cosecant"<<endl;
    cout<<"(6) Secant"<<endl;
    cout<<endl;
    cout<<"Enter the function that you want to perform : ";
    cin>>c;


    history<<"**************************************************************"<<endl;
    history<<asctime(localtime(&ctt))<<endl;cout<<endl;
    history<<"**************************************************************"<<endl;
    history<<"Trigonometric Operation"<<endl;
    history<<endl<<endl;
    history<<"(1) Cosine"<<endl;
    history<<"(2) Sine"<<endl;
    history<<"(3) Tangent"<<endl;
    history<<"(4) Cotangent"<<endl;
    history<<"(5) Cosecant"<<endl;
    history<<"(6) Secant"<<endl;
    history<<endl<<endl;
    history<<"Enter the function that you want to perform : "<<endl;
    history<<c<<endl;
    history<<endl;
    switch(c)
{

    case 1:
        history<<"-----------------";
        history<<"Cosine Operation"<<endl;
        history<<"-----------------";
        history<<endl;
        cout << "Please enter the value of degree : ";
        cin >> degrees;
        cout <<endl;
        history<< "Please enter the value of degree : ";
        history<<degrees;
        history<<endl<<endl;
        x = degrees*3.14159/180;
        result = cos(x);
        cout << "cos(" << degrees << ") = "  << result << " radian" << endl;
        history<< "cos(" << degrees << ") = "  << result << " radian" << endl;
        break;

    case 2:
        history<<"-----------------";
        history<<"Sine Operation"<<endl;
        history<<"-----------------";
        history<<endl;
        cout << "Please enter the value of degree : ";
        cin >> degrees;
        cout <<endl;
        history<< "Please enter the value of degree : ";
        history<<degrees;
        history<<endl<<endl;
        x = degrees*3.14159/180;
        result = sin(x);
        cout << "sin(" << degrees << ") = "  << result << " radian" << endl;
        history<< "sin(" << degrees << ") = "  << result << " radian" << endl;
        break;
    break;

    case 3:
        history<<"-----------------";
        history<<"Tangent Operation"<<endl;
        history<<"-----------------";
        history<<endl;
        cout << "Please enter the value of degree : ";
        cin >> degrees;
        cout <<endl;
        history<< "Please enter the value of degree : ";
        history<<degrees;
        history<<endl<<endl;
        x = degrees*3.14159/180;
        result = tan(x);
        cout << "tan(" << degrees << ") = "  << result << " radian" << endl;
        history<< "tan(" << degrees << ") = "  << result << " radian" << endl;
        break;

    case 4:
        history<<"-----------------";
        history<<"Contangent Operation"<<endl;
        history<<"-----------------";
        history<<endl;
        cout << "Please enter the value of degree : ";
        cin >> degrees;
        history<< "Please enter the value of degree : ";
        history<<degrees;
        x = 1/tan(degrees);
        result = x;
        cout << "cot(" << degrees << ") = "  << result << " radian"<<endl;
        history<< "cot(" << degrees << ") = "  << result << " radian"<<endl;
        history<<endl;
        break;

    case 5:
        history<<"-----------------";
        history<<"Cosecant Operation"<<endl;
        history<<"-----------------";
        history<<endl;
        cout << "Please enter the value of degree : ";
        cin >> degrees;
        history<< "Please enter the value of degree : ";
        history<<degrees;
        x = 1/sin(degrees);
        result = x;
        cout << "csc(" << degrees << ") = "  << result << " radian"<<endl;
        history<< "csc(" << degrees << ") = "  << result << " radian"<<endl;
        history<<endl;
        break;

    case 6:
        history<<"-----------------";
        history<<"Secant Operation"<<endl;
        history<<"-----------------";
        history<<endl;
        cout << "Please enter the value of degree : ";
        cin >> degrees;
        history<< "Please enter the value of degree : ";
        history<<degrees;
        x = 1/cos(degrees);
        result = x;
        cout << "csc(" << degrees << ") = "  << result << " radian"<<endl;
        history<< "csc(" << degrees << ") = "  << result << " radian"<<endl;
        history<<endl;
        break;

    default:
        cout<<"Wrong Input"<<endl;
        history<<"Wrong Input"<<endl;
        }
        cout<<endl;
        cout<<"Please enter (y) to continue or (n) to exit: ";
        cin>>conti;
        cout<<endl<<endl;
        history <<endl<<endl;
        history <<"Please enter (y) to continue or (n) to exit: ";
        history<<conti<<endl;
        history <<endl<<endl;
}
   while(conti=='y'||conti=='Y');

	cout << "The result will save in the file."<<endl;
	history<< "The result will save in the file."<<endl;;
	history.close();
	cout << "Done.\n";
	history << "Done.\n";
    return 0;
    }

    int q3()
{
    ofstream history;
    history.open("history.txt",fstream::app);
    history<<"**************************************************************"<<endl;
    history<<asctime(localtime(&ctt))<<endl;
    history<<"**************************************************************"<<endl;

    int Choice;

    system("cls");
    cout << "Please choose your desired conversion: " << endl;
    cout <<endl;
    cout << "(1) Decimal to Binary"<<endl;
    cout << "(2) Decimal to Hexadecimal"<<endl;
    cout << "(3) Binary to Decimal"<<endl;
    cout << "(4) Binary to Hexadecimal"<<endl;
    cout << "(5) Hexadecimal to Decimal"<<endl;
    cout << "(6) Hexadecimal to Binary"<<endl;
    cout << "(7) Exit"<<endl;
    cout<<endl;
    cout << "Your choice : ";
    cin >> Choice;

    switch(Choice)
    {
        case 1:
        {
            system ("cls");
            int dec, bin, yes;
            cout << "Enter the number : ";
            cin >> dec;
            history << "Enter the number : ";
            history << dec;
            if (dec < 0)
                {
                    cout << dec << " is not a positive integer." << endl;
                    history << dec << " is not a positive integer." << endl;
                }
            else
                {
                    cout << "The binary form of " << dec << " is ";
                    history << "The binary form of " << dec << " is ";
                    binary(dec);
                }
            cout<<endl;
            cout << "Do you wish to continue with another operation?"<<endl;
            cout << "(1) Yes"<<endl;
            cout << "(2) No"<<endl;
            cout << "Your choice : ";
            cin >> yes;

            if(yes == 1){
                    q3();
            }
            else{
                    system("cls");
            cout<<"Thank you!"<<endl;
            cout << "The result will save in the file."<<endl;
            history << "The result will save in the file."<<endl;
            cout << "Done."<<endl;
            history << "Done."<<endl;
            history.close();
            }
        }break;

        case 2:
        {
            system ("cls");
            int x, yes;
            cout << "Please enter the decimal number: " << endl;
            cin >> dec >> x;
            cout << "The hexadecimal form of the number is " << hex << x << endl;
            history << "Please enter the decimal number: " << endl;
            history << dec << x;
            history << "The hexadecimal form of the number is " << hex << x << endl;
            cout<<endl;
            cout << "Do you wish to continue with another operation?"<<endl;
            cout <<endl;
            cout << "(1) Yes"<<endl;
            cout << "(2) No"<<endl;
            cout << "Your choice : ";
            cin >> yes;

            if(yes == 1){
                    q3();
            }
            else{
                    system("cls");
            cout<<"Thank you!"<<endl;
            cout << "The result will save in the file."<<endl;
            history << "The result will save in the file."<<endl;
            cout << "Done."<<endl;
            history << "Done."<<endl;
            history.close();
            }
        }break;

        case 3:
        {
            system ("cls");
            long bin, dec = 0, rem, num, base = 1;
            int yes;
            cout << "Enter the binary number(1s and 0s) : ";
            cin >> num;
            history << "Enter the binary number(1s and 0s) : ";
            history << num;

            bin = num;
            while (num > 0)
                {
                    rem = num % 10;
            dec = dec + rem * base;
            base = base * 2;
            num = num / 10;
            }
            cout << "The decimal equivalent of " << bin << " : " << dec << endl;
            history << "The decimal equivalent of " << bin << " : " << dec << endl;
            cout<<endl;
            cout << "Do you wish to continue with another operation?"<<endl;
            cout <<endl;
            cout << "(1) Yes"<<endl;
            cout << "(2) No"<<endl;
            cout << "Your choice : ";
            cin >> yes;

            if(yes == 1){
                    q3();
            }
            else{
                    system("cls");
            cout<<"Thank you!"<<endl;
            cout << "The result will save in the file."<<endl;
            history << "The result will save in the file."<<endl;
            cout << "Done."<<endl;
            history << "Done."<<endl;
            history.close();
            }
        }break;

        case 4:
        {
            system ("cls");
                char binnum[MAX], hexa[MAX], x;
        int temp, yes;
        long int i=0,j=0;
        cout<<endl;
        cout<<"Enter Binary Number : ";
        cin>>binnum;

        history<<endl;
        history<<"Enter Binary Number : ";
        history<<binnum;
        while(binnum[i])
        {
                binnum[i] = binnum[i] -48;
                ++i;
        }
        --i;
        while(i-2>=0)
        {
                temp =  binnum[i-3] *8 + binnum[i-2] *4 +  binnum[i-1] *2 + binnum[i] ;
                if(temp > 9)
                        hexa[j++] = temp + 55;
                else
                        hexa[j++] = temp + 48;
                i=i-4;
        }
        if(i ==1)
                hexa[j] = binnum[i-1] *2 + binnum[i] + 48 ;
        else if(i==0)
                hexa[j] =  binnum[i] + 48 ;
        else
                --j;
        cout<<endl;
        cout<<"Binary Number to Hexadecimal Number : ";
        history<<endl;
        history<<"Binary Number to Hexadecimal Number : ";
        while(j>=0)
        {
                x = hexa[j--];
                cout<< x;
                history << x;
        }   history << endl;
cout<<endl;
cout<<endl;
cout << "Do you wish to continue with another operation?"<<endl;
cout << "(1) Yes"<<endl;
cout << "(2) No"<<endl;
cout << "Your choice : ";
cin >> yes;

if(yes == 1){
    q3();
}
else{
    system("cls");
    cout<<"Thank you!"<<endl;
    cout << "The result will save in the file."<<endl;

	history << "The result will save in the file."<<endl;

	cout << "Done."<<endl;

	history << "Done."<<endl;
	history.close();
}
        }break;

        case 5:
        {
            system ("cls");
               int x, yes;

    cout << "Please enter the Hexadecimal number : ";
    cin >> hex >> x;
    cout<<endl;
    cout << "The Decimal value is : " << dec << x;

    history << "Please enter the Hexadecimal number : ";
    history << hex << x;
    history<<endl;
    history << "The Decimal value is : " << dec << x;

cout<<endl;
cout<<endl;
cout << "Do you wish to continue with another operation?"<<endl;
cout << "(1) Yes"<<endl;
cout << "(2) No"<<endl;
cout << "Your choice : ";
cin >> yes;

if(yes == 1){
    q3();
}
else{
    system("cls");
    cout<<"Thank you!"<<endl;
    cout << "The result will save in the file."<<endl;

	history << "The result will save in the file."<<endl;

	cout << "Done."<<endl;

	history << "Done."<<endl;
	history.close();
}
        }break;

        case 6:
        {
            system ("cls");
            int i=0, yes;
            char hex[15];
            cout << "Enter your desired Hexadecimal value : ";
            cin >> hex;
            cout<<endl;
            cout << "The Binary value is : ";

            history << "Enter your desired Hexadecimal value : "<<endl;
            history << hex<<endl;
            history<<endl<<endl;
            history << "The Binary value is : ";

            while(hex[i])
                {
                    switch(hex[i])
                    {
                        case '0' : cout<<"0000";
                        history<<"0000";
                        break;
                        case '1' : cout<<"0001";
                        history<<"0001";
                        break;
                        case '2' : cout<<"0010";
                        history<<"0010";
                        break;
                        case '3' : cout<<"0011";
                        history<<"0011";
                        break;
                        case '4' : cout<<"0100";
                        history<<"0100";
                        break;
                        case '5' : cout<<"0101";
                        history<<"0101";
                        break;
                        case '6' : cout<<"0110";
                        history<<"0110";
                        break;
                        case '7' : cout<<"0111";
                        history<<"0111";
                        break;
                        case '8' : cout<<"1000";
                        history<<"1000";
                        break;
                        case '9' : cout<<"1001";
                        history<<"1001";
                        break;
                        case 'A' : cout<<"1010";
                        history<<"1010";
                        break;
                        case 'B' : cout<<"1011";
                        history<<"1011";
                        break;
                        case 'C' : cout<<"1100";
                        history<<"1100";
                        break;
                        case 'D' : cout<<"1101";
                        history<<"1101";
                        break;
                        case 'E' : cout<<"1110";
                        history<<"1110";
                        break;
                        case 'F' : cout<<"1111";
                        history<<"1111";
                        break;
                        case 'a' : cout<<"1010";
                        history<<"1010";
                        break;
                        case 'b' : cout<<"1011";
                        history<<"1011";
                        break;
                        case 'c' : cout<<"1100";
                        history<<"1100";
                        break;
                        case 'd' : cout<<"1101";
                        history<<"1101";
                        break;
                        case 'e' : cout<<"1110";
                        history<<"1110";
                        break;
                        case 'f' : cout<<"1111";
                        history<<"1111";
                        break;
                        default :
                            cout<<endl;
                            cout<<"Invalid hexadecimal digit "<<hex[i];
                        history<<endl;
                        history<<"Invalid hexadecimal digit "<<hex[i];
                    }
                i++;
                }
                cout<<endl;
                cout<<endl;
                cout << "Do you wish to continue with another operation?"<<endl;
                cout << "(1) Yes"<<endl;
                cout << "(2) No"<<endl;
                cout << "Your choice : ";
                cin >> yes;
            if(yes == 1){
                    q3();
            }
            else{
                    system("cls");
            cout<<"Thank you!"<<endl;
            cout << "The result will save in the file."<<endl;
            history << "The result will save in the file."<<endl;
            cout << "Done."<<endl;
            history << "Done."<<endl;
            history.close();
            }

        }break;

        case 7:
        {
            system("cls");
            cout << "Thank you!"<<endl;
        }break;

        default: main();
    }
}

void binary (int num)
{
    ofstream history;
    history.open("history.txt",fstream::app);

    int rem;

    if (num <= 1)
    {
        cout << num;

        history << rem;
        return;
    }
    rem = num % 2;
    binary (num / 2);
    cout << rem;

    history << rem;
}

int q2()
{
    ofstream history;
    history.open ("history.txt",ofstream::app);

    history<<"**************************************************************"<<endl;
    history<<asctime(localtime(&ctt))<<endl;
    history<<"**************************************************************"<<endl;

	int mat1[10][10], mat2[10][10], mult[10][10], row1, col1, row2, col2, i, j, k,choice;
    cout<< "Matrix Calculator"<<endl;
    cout<<endl;
	cout << "Enter rows and column for first matrix: "<<endl;
	cin >> row1 >> col1;                                      //number of 1st row and column
	cout << "Enter rows and column for second matrix: "<<endl;
	cin >> row2 >> col2;                                      //number of 2nd row and column

    history<< "Matrix Calculator"<<endl;
    history<<endl<<endl;
	history << "Enter rows and column for first matrix: "<<endl;
	history << row1 <<endl<< col1<<endl;
	history << "Enter rows and column for second matrix: "<<endl;
	history << row2 <<endl<< col2<<endl;

	while (col1 != row2)
	{
		cout << "Error! column of first matrix not equal to row of second." << endl;
		cout << "Enter rows and column for first matrix: "<<endl;                            //coumn 1st == row2nd
		cin >> row1 >> col1;                                              //reinput
		cout << "Enter rows and column for second matrix: "<<endl;
		cin >> row2 >> col2;                                              //reinput

		history << "Error! column of first matrix not equal to row of second." << endl;
		history << "Enter rows and column for first matrix: "<<endl;
		history << row1 <<endl<< col1<<endl;
		history << "Enter rows and column for second matrix: "<<endl;
		history <<row2 <<endl<< col2<<endl;


	}
        input(mat1, mat2, row1, col1, row2, col2);
    while(choice!=4){
        cout<<endl;
        cout<<"Choose operation"<<endl;
        cout<<endl;
        cout<<"(1) - Addition"<<endl;
        cout<<"(2) - Subtraction"<<endl;
        cout<<"(3) - Multiplication"<<endl;
        cout<<"(4) - Exit"<<endl<<endl;
        cout<<"Enter the choice: ";
        cin>>choice;

        history<<endl<<endl;
        history<<"Choose operation"<<endl;
        history<<endl;
        history<<"(1) - Addition"<<endl;
        history<<"(2) - Subtraction"<<endl;
        history<<"(3) - Multiplication"<<endl;
        history<<"(4) - Exit"<<endl<<endl;
        history<<"Enter the choice: ";
        history<<choice<<endl;


        if(choice==1)
        {
            cout<<endl;
        addition(mat1, mat2, mult, row1, col1, row2, col2);
        int i, j;
	cout << "Output Matrix: " << endl;
	history << "Output Matrix:" << endl;
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			cout <<"["<< mult[i][j] << "] ";
			history <<"["<< mult[i][j] << "] ";
			if(j == col2 - 1)
                {
				cout << endl<<endl;
				history<<endl<<endl;

                }
		}
	}
        cout<<endl;
        }
        else if(choice==2)
        {
            cout<<endl;
        subtract(mat1, mat2, mult, row1, col1, row2, col2);
        int i, j;
	cout << "Output Matrix: " << endl;
	history << "Output Matrix:" << endl;
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			cout <<"["<< mult[i][j] << "] ";
			history <<"["<< mult[i][j] << "] ";
			if(j == col2 - 1)
                {
				cout << endl<<endl;
				history<<endl<<endl;

                }
		}
	}
        cout<<endl;
        }
        else if(choice==3)
        {
            cout<<endl;
        multiply(mat1, mat2, mult, row1, col1, row2, col2);
        int i, j;
	cout << "Output Matrix: " << endl;
	history << "Output Matrix:" << endl;
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			cout <<"["<< mult[i][j] << "] ";
			history <<"["<< mult[i][j] << "] ";
			if(j == col2 - 1)
                {
				cout << endl<<endl;
				history<<endl<<endl;

                }
		}
	}
        cout<<endl;
        }
        else
        {
            cout<<"Invalid number"<<endl;
            history<<"Invalid number"<<endl;
            system("cls");
        }}
    cout<<endl;
    cout<<"The result will save into the file"<<endl;
    cout<<endl;
    history.close();
	return 0;
}

void input(int mat1[][10], int mat2[][10], int row1, int col1, int row2, int col2)
{
	int i, j;
	ofstream history;
    history.open ("history.txt",ofstream::app);

	cout << endl << "Enter elements of matrix 1" << endl;                //receive input element for matrix 1
	history << endl << "Enter elements of matrix 1" << endl;
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col1; ++j)
		{
			cout << "Enter elements a"<< i + 1 << j + 1 << ": ";
			cin >> mat1[i][j];
			history << "Enter elements a"<< i + 1 << j + 1 << ": ";
			history << mat1[i][j]<<endl;
		}
	}

	cout << endl << "Enter elements of matrix 2" << endl;                 //receive input element for matrix 2
	history<< endl << "Enter elements of matrix 2" << endl;
	for(i = 0; i < row2; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			cout << "Enter elements b" << i + 1 << j + 1 << ": ";
			cin >> mat2[i][j];
			history << "Enter elements b" << i + 1 << j + 1 << ": ";
			history << mat2[i][j]<<endl;
		}
	}
}

void addition(int mat1[][10], int mat2[][10], int mult[][10], int row1, int col1, int row2, int col2)
{
	int i, j, k;

	// initialize element of matrix mult to 0.
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			mult[i][j] = 0;
		}
	}

	// addition matrix mat_1st and mat_2nd and storing in array mult.
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			for(k=0; k<col1; ++k)
			{
				mult[i][j] += mat1[i][k] + mat2[k][j];
			}
		}
	}
}

void subtract(int mat1[][10], int mat2[][10], int mult[][10], int row1, int col1, int row2, int col2)
{
	int i, j, k;

	// initialize element of matrix mult to 0.
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			mult[i][j] = 0;
		}
	}

	// subtraction matrix mat_1st and mat_2nd and storing in array mult.
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			for(k=0; k<col1; ++k)
			{
				mult[i][j] += mat1[i][k] - mat2[k][j];
			}
		}
	}
}

void multiply(int mat1[][10], int mat2[][10], int mult[][10], int row1, int col1, int row2, int col2)
{
    ofstream history;
    history.open ("history.txt",ofstream::app);

	int i, j, k;
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			mult[i][j] = 0;
		}
	}
	for(i = 0; i < row1; ++i)
	{
		for(j = 0; j < col2; ++j)
		{
			for(k=0; k<col1; ++k)
			{
				mult[i][j] += mat1[i][k] * mat2[k][j];
			}
		}
	}
}

int q1()
{

    float a,b,d;
    char conti;
    int c;

	// Open an output file.
	ofstream history;
	history.open("history.txt",fstream::app);
    do
    {
        ofstream history;
        history.open("history.txt",fstream::app);
        cout<<"Operations In Scalar"<<endl;
        cout<<endl;
        cout<<"(1) Addition"<<endl;
        cout<<"(2) Subtraction"<<endl;
        cout<<"(3) Multiplication"<<endl;
        cout<<"(4) Division"<<endl;
        cout<<endl;
        cout<<"Please choose: ";
        cin>>c;
        cout<<endl;

        history<<"**************************************************************"<<endl;
        history<<asctime(localtime(&ctt))<<endl;
        history<<"**************************************************************"<<endl;
        history<<"Operations In Scalar Value"<<endl;
        history<<endl;
        history<<"Please choose: "<<endl;
        history<<c<<endl;
        history<<endl<<endl;
    switch(c)
    {
    case 1:
        history<<"Addition Operation"<<endl;
        history<<endl;

        cout<<"Enter first number : ";
        cin>>a;
        history<<"Enter first number : "<<endl;
        history<<a<<endl;
        cout<<"Enter second number : ";
        cin>>b;
        cout<<endl;
        history<<"Enter second number : "<<endl;
        history<<b<<endl;
        d=a+b;

        cout<<"Sum of this two number is = "<<a+b<<endl;
        history<<"Sum of this two number is = "<<a+b<<endl;
        break;
        default:
        cout<<"Wrong Input"<<endl;
        history<<"Wrong Input"<<endl;
    break;
    case 2:
        history<<"Subtraction Operation"<<endl;
        history<<endl;

        cout<<"Enter first number : ";
        cin>>a;
        history<<"Enter first number : "<<endl;
        history<<a<<endl;
        cout<<"Enter second number : ";
        cin>>b;
        cout<<endl;
        history<<"Enter second number : "<<endl;
        history<<b<<endl;
        d=a+b;

        cout<<"Subtraction of this two number is = "<<a-b<<endl;
        history<<"Subtraction of this two number is = "<<a-b<<endl;

    break;
    case 3:
        history<<"Multiplication Operation"<<endl;
        history<<endl;

      cout<<"Enter first number : ";
        cin>>a;
        history<<"Enter first number : "<<endl;
        history<<a<<endl;
        cout<<"Enter second number : ";
        cin>>b;
        cout<<endl;
        history<<"Enter second number : "<<endl;
        history<<b<<endl;
        d=a+b;

        cout<<"Multiplication of this two number is = "<<a*b<<endl;
        history<<"Multiplication of this two number is = "<<a*b<<endl;

    break;
    case 4:
        history<<"Division Operation"<<endl;
        history<<endl;

        cout<<"Enter first number : ";
        cin>>a;
        history<<"Enter first number : "<<endl;
        history<<a<<endl;
        cout<<"Enter second number : ";
        cin>>b;
        cout<<endl;
        history<<"Enter second number : "<<endl;
        history<<b<<endl;
        d=a+b;

        cout<<"Division of this two number is = "<<a/b<<endl;
        history<<"Division of this two number is = "<<a/b<<endl;

    }
    cout<<endl;
    cout<<"Please enter (y) to continue or (n) to exit: ";
    cin>>conti;
    cout<<endl<<endl;

}
    while(conti=='y'||conti=='Y');


	cout << "The result will save in the file."<<endl;
	cout<<endl;
	history << "The result will save in the file."<<endl;
	history<<endl<<endl;

// Close the file.
history.close();
return 0;
}







# data[].attributes.body
aliff iqbal
muhammad zulhelmi
muhammad naim

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<stdlib.h>
#include <fstream>
#include<cmath>
#include<windows.h>
#include<iomanip>
#include <cstring>
#include <string>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <stdio.h>
#define MAX 1000
#define BASE_16 16

using namespace std;

struct rectangle
{
    float length;
    float height;
    float width;
};
void binary(int num)
{
    int rem;

    if (num <= 1)
    {
        cout << num;
        return;
    }
    rem = num % 2;
    binary(num / 2);
    cout << rem;
}
const double PI = 3.14159265;

void measureObject (float area, float perimeter, float volume);

void buat_tambah(float num1,float num2,float ans1,int operation, char user);
void buat_tolak(float num3,float num4,float ans2,int operation1,char user);
void buat_darab(float num1,float num4,float ans3,int operation2, char user);
void buat_bahagi(float num1,float num4,float ans4,int operation3, char user);
void electrical_charge(float num1,float num2,float ans1,int operation, char user);
void capacitance(float num3,float num4,float ans2,int operation1,char user);
void current_voltage(float num1,float num4,float ans3,int operation2, char user);
void power(float num1,float num4,float ans4,int operation3, char user);
void findRoot(int, int, int);
void hexatobinary();
void decimaltobinary();
void decimaltohexa();
void hexatodecimal();
void binarytohexa();
void binarytodecimal();
void OperationList ();
void P1();
void dectoBinHex();
void bintoDecHex();
void hextoDecBin();
float calcChar(float, float);
float calcCapa(float, float);
float calcCurr(float, float);
float calcVolt(float, float);
float calcPow(float, float);
void calcRect();
void calcCirc();
float calcRoot(float, float, float);











int main()
{
int num;
cout << "      ________________________________________________________________________________________________________________________________\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     |                                         ENGINEERING CALCULATOR SELECTER                                                        |\n" ;
cout << "     | _______________________________________________________________________________________________________________________________|\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 1. Addition, Subtraction, Multiplication and Division operation of scalar value                                                |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 2. Addition, Subtraction and Multiplication of matrices                                                                        |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 3. conversion between Binary Value, Hexadecimal Value and Decimal Value                                                        |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 4. Trigonometric Operation such as finding Cosine, Sine, Tangent, Cotangent, Cosecant and Secant                               |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 5. Compute Electrical Charge, Capacitance, Current, Voltage and Power, given that required parameter are given by user         |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 6. Compute Perimeter / Circumference, Area and Volume of Rectangles and Circle, given that required parameter are given by user|\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 7. Solve Root of Quadratic Equation                                                                                            |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | 8. Exit                                                                                                                        |\n" ;
cout << "     |                                                                                                                                |\n" ;
cout << "     | SELECT NUMBER OF FUNCTION CALCULATOR                                                                                           |\n" ;
cout << "     |________________________________________________________________________________________________________________________________|\n";
cin >> num ;
system("cls");


switch (num)
{
case 1:
{
    float num1, num2, num3, num4, ans1, ans2, ans3, ans4;
    int operation, operation1, operation2, operation3;
    char user;
    num1=0;

    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                                                                                      \n";
    cout<<"     _______________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

    cin>>num1;
    system("cls");
     cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                 \t"<<num1<<"\t                                                       \n";
    cout<<"     ________________________________________________________________________________\n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                    \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

      cin>>user;
      system("cls");


      if(user=='p'){
        buat_tambah(num1,num2,ans1,operation,user);
      }
       if(user=='m'){
        buat_tolak(num1,num4,ans2,operation1,user);
      }
       if(user=='t'){
        buat_darab(num1,num4,ans3,operation2,user);
      }
       if(user=='d'){
        buat_bahagi(num1,num4,ans4,operation3,user);
      }

    }
    break;

case 2:
            {
fstream dataMatrices;
    int calc,row,column,c,d,first[50][50],second[50][50],sum[50][50];
    char history2;

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                            Choose one of the calculations:                           \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Addition of matrices                                      \n";
    cout<<"       7  |  8  |  9  |  2. Subtraction of matrices                                   \n";
    cout<<"          |  0  |     |  3. Multiplication of matrices                                \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> calc;
    system("cls");
    dataMatrices.open("matrices.txt", ios::out|ios::app);
    switch(calc)
    {
        case 1:
            {
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                    Enter the number of rows and columns of matrix:                   \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Addition of matrices                                      \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> row >> column;
    system("cls");

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                   \t\t rows : "<<row<<" and columns : "<<column<<"\t\t               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Addition of matrices                                      \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout << "Enter the elements of first matrix:\n";

        for(c=0;c<row;c++)
            for(d=0;d<column;d++)
                {
                    cin >> first[c][d];
                }

    cout << "Enter the elements of second matrix:\n";

        for(c=0;c<row;c++)
            for(d=0;d<column;d++)
                {
                    cin >> second[c][d];
                }
    system("cls");
    cout<< " First matrix "<<endl;
    cout<< "--------------"<<endl;
    for (int c=0;c<row;c++)
        {
            for (int d=0;d<column;d++)
                {
                    cout << first[c][d]<< "\t";
                }
                cout <<endl;
        }
    cout<< " Second matrix "<<endl;
    cout<< "---------------"<<endl;
    for (int c=0;c<row;c++)
        {
            for (int d=0;d<column;d++)
                {
                    cout << second[c][d]<< "\t";
                }
                cout <<endl;
        }
    cout << " Sum of entered matrices:\n";
    cout << "-------------------------"<<endl;
        for(c=0;c<row;c++)
            {
                for(d=0;d<column;d++)
            {
            sum[c][d] = first[c][d] + second[c][d];
            cout << sum[c][d] << "\t";
            }
                cout << endl;
            }
            cout << endl;
            break;
}

        case 2:
            {
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                    Enter the number of rows and columns of matrix:                   \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  2. Subtraction of matrices                                   \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> row >> column;
     system("cls");

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                   \t\t rows : "<<row<<" and columns : "<<column<<"\t\t               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  2. Subtraction of matrices                                   \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout << "Enter the elements of first matrix:\n";

        for(c=0;c<row;c++)
            for(d=0;d<column;d++)
                {
                    cin >> first[c][d];
                }

    cout << "Enter the elements of second matrix:\n";

        for(c=0;c<row;c++)
            for(d=0;d<column;d++)
                {
                    cin >> second[c][d];
                }
    system("cls");
    cout<< " First matrix "<<endl;
    cout<< "--------------"<<endl;
    for (int c=0;c<row;c++)
        {
            for (int d=0;d<column;d++)
                {
                    cout << first[c][d]<< "\t";
                }
                cout <<endl;
        }
    cout<< " Second matrix "<<endl;
    cout<< "---------------"<<endl;
    for (int c=0;c<row;c++)
        {
            for (int d=0;d<column;d++)
                {
                    cout << second[c][d]<< "\t";
                }
                cout <<endl;
        }
    cout << " Total of entered matrices:\n";
    cout << "----------------------------"<<endl;

        for(c=0;c<row;c++)
            {
                for(d=0;d<column;d++)
                {
                    sum[c][d] = first[c][d] - second[c][d];
                    cout << sum[c][d] << "\t";
                }
                cout << endl;
            }
    break;

}

        case 3:
            {
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                    Enter the number of rows and columns of matrix:                   \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  3. Multiplication of matrices                                \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> row >> column;
    system("cls");

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                   \t\t rows : "<<row<<" and columns : "<<column<<"\t\t               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  3. Multiplication of matrices                                \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    cout << "Enter the elements of first matrix:\n";

        for(c=0;c<row;c++)
            for(d=0;d<column;d++)
                {
                    cin >> first[c][d];
                }

    cout << "Enter the elements of second matrix:\n";

        for(c=0;c<row;c++)
            for(d=0;d<column;d++)
                {
                    cin >> second[c][d];
                }
    system("cls");
    cout<< " First matrix "<<endl;
    cout<< "--------------"<<endl;
    for (int c=0;c<row;c++)
        {
            for (int d=0;d<column;d++)
                {
                    cout << first[c][d]<< "\t";
                }
                cout <<endl;
        }
    cout<< " Second matrix "<<endl;
    cout<< "---------------"<<endl;
    for (int c=0;c<row;c++)
        {
            for (int d=0;d<column;d++)
                {
                    cout << second[c][d]<< "\t";
                }
                cout <<endl;
        }

    cout << " Product of entered matrices:\n";
    cout << "------------------------------"<<endl;

        for(c=0;c<row;c++)
            {
                for(d=0;d<column;d++)
            {
                sum[c][d] = first[c][d] * second[c][d];
                cout << sum[c][d] << "\t";
                    }
                        cout << endl;
                    }
                cout << endl;
                break;
            }
    }
    system("pause");
    system("cls");
    cout << "\n Do you want to view history? (Press Y for Yes/N for No): ";
    cin >> history2;
    if(history2 == 'Y')
    {
        cout << endl;
        for(c=0;c<row;c++)
        {
            for(d=0;d<column;d++)
            {
                dataMatrices >> sum[c][d];
                cout << sum[c][d] << "\t";
            }
            cout << endl;
            system("pause");
            system("cls");
            main();
        }
    }
    else if (history2 == 'N')
        cout << endl;
        dataMatrices.close();
        system("pause");
        system("cls");
        main();

    return 0;
            }
    break;

case 3:
            {
int pilih;

            ofstream openFile;
            openFile.open("History.txt",fstream::app);

            system("cls");
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                  Choose from 1 to 7                                  \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
            cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
            cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
            cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
            cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
            cout<<"          |     |     |     6. Binary to Decimal                                      \n";
            cout<<"          |     |     |     7. Exit                                                   \n";
            cout<<"     _______________________________________________________________________________  \n";

            cin >> pilih;
            switch(pilih)
            {
            case 1:
                {
                    system("cls");
                    int dec, bin;
                    cout << "Enter the number : ";
                    cin >> dec;

                    openFile << "Enter the number : ";
                    openFile << dec;

                    if (dec < 0)
                        {
                            cout<<"      ________________________________________________________________________________\n";
                            cout<<"                                                                                      \n";
                            cout<<" "                          <<dec << " is not a positive integer.                     \n";
                            cout<<"     ________________________________________________________________________________ \n";
                            cout<<"      Number | Button |  Operation                                                    \n";
                            cout<<"     ________|________|______________________________________________________________ \n";
                            cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
                            cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
                            cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
                            cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
                            cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
                            cout<<"          |     |     |     6. Binary to Decimal                                      \n";
                            cout<<"          |     |     |     7. Exit                                                   \n";
                            cout<<"     _______________________________________________________________________________  \n";
                        }

                    else
                        {
                            cout<<"     ________________________________________________________________________________\n";
                            cout<<"                                                                                      \n";
                            cout<<"                        The binary form of " << dec << " is "; binary(dec); cout << " \n";
                            cout<<"     ________________________________________________________________________________ \n";
                            cout<<"      Number | Button |  Operation                                                    \n";
                            cout<<"     ________|________|______________________________________________________________ \n";
                            cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
                            cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
                            cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
                            cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
                            cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
                            cout<<"          |     |     |     6. Binary to Decimal                                      \n";
                            cout<<"          |     |     |     7. Exit                                                   \n";
                            cout<<"     _______________________________________________________________________________  \n";

                            cout << endl;

                        }
                system("pause");
                break;
                }

            case 2:
                {
                    system("cls");
                    char binaryValues[MAX],hexaValues[MAX];
                    long int i=0;

                    cout<<"Enter any hexadecimal number: ";
                    cin>>hexaValues;



                    cout<<"Equivalent binary value: ";
                    while(hexaValues[i])
                        {
                            switch(hexaValues[i])
                                {
                                    case '0': cout<<"0000"; break;
                                    case '1': cout<<"0001"; break;
                                    case '2': cout<<"0010"; break;
                                    case '3': cout<<"0011"; break;
                                    case '4': cout<<"0100"; break;
                                    case '5': cout<<"0101"; break;
                                    case '6': cout<<"0110"; break;
                                    case '7': cout<<"0111"; break;
                                    case '8': cout<<"1000"; break;
                                    case '9': cout<<"1001"; break;
                                    case 'A': cout<<"1010"; break;
                                    case 'B': cout<<"1011"; break;
                                    case 'C': cout<<"1100"; break;
                                    case 'D': cout<<"1101"; break;
                                    case 'E': cout<<"1110"; break;
                                    case 'F': cout<<"1111"; break;
                                    case 'a': cout<<"1010"; break;
                                    case 'b': cout<<"1011"; break;
                                    case 'c': cout<<"1100"; break;
                                    case 'd': cout<<"1101"; break;
                                    case 'e': cout<<"1110"; break;
                                    case 'f': cout<<"1111"; break;
                                    default:  cout<<"Invalid hexadecimal digit "<<hexaValues[i];
                                }
                            i++;
                    }
                    cout << endl;
                    system("pause");
                    break;
                }

            case 3:
                {
                    system("cls");
                    char hexValues[] = "0123456789ABCDEF";
                    long decimal;
                    char hexadecimal[40];
                    int index, remainder;

                    cout << "Please enter decimal number: ";
                    cin >> decimal;

                    index = 0;

                    while (decimal != 0)
                        {
                            remainder = decimal % BASE_16;
                            hexadecimal[index] = hexValues[remainder];
                            decimal /= BASE_16;
                            index++;
                        }

                        hexadecimal[index] = '\0';

                        strrev(hexadecimal);

                        cout<<"     ________________________________________________________________________________\n";
                        cout<<"                                                                                      \n";
                        cout<<"                        hexadecimal number : " << hexadecimal <<                    " \n";
                        openFile<<"hexadecimal number : " << hexadecimal <<                    " \n";
                        cout<<"     ________________________________________________________________________________ \n";
                        cout<<"      Number | Button |  Operation                                                    \n";
                        cout<<"     ________|________|______________________________________________________________ \n";
                        cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
                        cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
                        cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
                        cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
                        cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
                        cout<<"          |     |     |     6. Binary to Decimal                                      \n";
                        cout<<"          |     |     |     7. Exit                                                   \n";
                        cout<<"     _______________________________________________________________________________  \n";

                        system("pause");
                        break;
                }

            case 4:
                {
                    system("cls");
                    int integer;
                    cout<<"Entex Hex to Convert hex to decimal"<<std::endl;
                    cin >> hex >> integer;

                    cout<<"     ________________________________________________________________________________\n";
                    cout<<"                                                                                      \n";
                    cout<<"                                   your decimal number is: " << integer << endl;
                    openFile<<"your decimal number is: " << integer << endl;
                    cout<<"     ________________________________________________________________________________ \n";
                    cout<<"      Number | Button |  Operation                                                    \n";
                    cout<<"     ________|________|______________________________________________________________ \n";
                    cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
                    cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
                    cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
                    cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
                    cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
                    cout<<"          |     |     |     6. Binary to Decimal                                      \n";
                    cout<<"          |     |     |     7. Exit                                                   \n";
                    cout<<"     _______________________________________________________________________________  \n";

                    cout << endl;
                    system("pause");
                    break;
                }

            case 5:
                {
                    system("cls");
                    long int binaryval, hexadecimalval = 0, i = 1, remainder;

                    printf("Enter the binary number: ");
                    scanf("%ld", &binaryval);
                    while (binaryval != 0)
                        {
                            remainder = binaryval % 10;
                            hexadecimalval = hexadecimalval + remainder * i;
                            i = i * 2;
                            binaryval = binaryval / 10;
                        }

                    cout<<"     ________________________________________________________________________________\n";
                    cout<<"                                                                                      \n";
                    printf("                            Equivalent hexadecimal value: %lX\n", hexadecimalval);
                    cout<<"     ________________________________________________________________________________ \n";
                    cout<<"      Number | Button |  Operation                                                    \n";
                    cout<<"     ________|________|______________________________________________________________ \n";
                    cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
                    cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
                    cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
                    cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
                    cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
                    cout<<"          |     |     |     6. Binary to Decimal                                      \n";
                    cout<<"          |     |     |     7. Exit                                                   \n";
                    cout<<"     _______________________________________________________________________________  \n";

                    cout << endl;
                    system("pause");
                    break;
                }

            case 6:
                {
                    system("cls");
                    long bin, dec = 0, rem, num, base = 1;
                    cout << "Enter the binary number(1s and 0s) : ";
                    cin >> num;
                    bin = num;
                    while (num > 0)
                        {
                            rem = num % 10;
                            dec = dec + rem * base;
                            base = base * 2;
                            num = num / 10;
                        }


                    cout<<"     ________________________________________________________________________________\n";
                    cout<<"                                                                                      \n";
                    cout<<"                         The decimal equivalent of " << bin << " : " << dec << endl;
                    openFile<<"The decimal equivalent of " << bin << " : " << dec << endl;
                    cout<<"     ________________________________________________________________________________ \n";
                    cout<<"      Number | Button |  Operation                                                    \n";
                    cout<<"     ________|________|______________________________________________________________ \n";
                    cout<<"       1  |  2  |  3  |     1. Decimal to Binary                                      \n";
                    cout<<"       4  |  5  |  6  |     2. Hexadecimal to Binary                                  \n";
                    cout<<"       7  |  8  |  9  |     3. Decimal to Hexadecimal                                 \n";
                    cout<<"          |  0  |     |     4. Hexadecimal to Decimal                                 \n";
                    cout<<"          |     |     |     5. Binary to Hexadecimal                                  \n";
                    cout<<"          |     |     |     6. Binary to Decimal                                      \n";
                    cout<<"          |     |     |     7. Exit                                                   \n";
                    cout<<"     _______________________________________________________________________________  \n";

                    cout << endl;
                    system("pause");
                    break;
                }
            case 7:
                {
                break;
                }
            }
    openFile.close();

    main();
            }
    break;

case 4:
            {

    int choice;
    double degrees, radians;

        ofstream openFile;
        openFile.open("History.txt",fstream::app);

        system("cls");

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 Enter angle in degrees:                              \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

            cin>>degrees;
            openFile << degrees << endl;

            system("cls");

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 Enter angle in degrees: "<< degrees <<"              \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

            radians = degrees * PI / 180.0;

            cin >> choice;
            switch(choice)
            {
            case 1:
                {
                    system("cls");
                    cout<<fixed<<showpoint<<setprecision(3);

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 cosine(degrees) =  " <<cos(radians)<< "       \n";
            openFile<<"cosine(degrees) =  " <<cos(radians)<< "       \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

                system("pause");
                break;
                }


            case 2:
                {
                    system("cls");
                    cout<<fixed<<showpoint<<setprecision(3);

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 sine(degrees) =  " << sin(radians)<< "       \n";
            openFile<<"sine(degrees) =  " << sin(radians)<< "       \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

                system("pause");
                break;
                }


            case 3:
                {
                    system("cls");
                    cout<<fixed<<showpoint<<setprecision(3);

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 tangent(degrees) =  " << tan(radians)<< "       \n";
            openFile<<"tangent(degrees) =  " << tan(radians)<< "       \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

                system("pause");
                break;
                }

            case 4:
                {
                    system("cls");
                    cout<<fixed<<showpoint<<setprecision(3);

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 secant(degrees) =  " << acos(radians)<< "       \n";
            openFile<<"secant(degrees) =  " << acos(radians)<< "       \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

                system("pause");
                break;
                }


            case 5:
                {
                    system("cls");
                    cout<<fixed<<showpoint<<setprecision(3);

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 cosecant(degrees) =  " << asin(radians)<< "       \n";
            openFile<<"cosecant(degrees) =  " << asin(radians)<< "       \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

                system("pause");
                break;
                }


            case 6:
                {
                    system("cls");
                    cout<<fixed<<showpoint<<setprecision(3);

            cout<<"     ________________________________________________________________________________ \n";
            cout<<"                                                                                      \n";
            cout<<"                                 cotangent(degrees) =  " << atan(radians)<< "       \n";
            openFile<<"cotangent(degrees) =  " << atan(radians)<< "       \n";
            cout<<"     ________________________________________________________________________________ \n";
            cout<<"      Number | Button |  Operation                                                    \n";
            cout<<"     ________|________|______________________________________________________________ \n";
            cout<<"       1  |  2  |  3  |      1. Cosine                                                \n";
            cout<<"       4  |  5  |  6  |      2. Sine                                                  \n";
            cout<<"       7  |  8  |  9  |      3. Tangent                                               \n";
            cout<<"          |  0  |     |      4. Cotangent                                             \n";
            cout<<"          |     |     |      5. Cosecant                                              \n";
            cout<<"          |     |     |      6. Secant                                                \n";
            cout<<"          |     |     |      7. Exit                                                  \n";
            cout<<"     _______________________________________________________________________________  \n";

                system("pause");
                break;

                }
            case 7:
                break;

            }
            openFile.close();

main();

            return 0;
            }
    break;

case 5:
            {
    float num1, num2, num3, num4, ans1, ans2, ans3, ans4;
    int operation, operation1, operation2, operation3;
    char user;
    num1=0;

    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                                                                                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

    cin>>num1;
    system("cls");
     cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                 \t"<<num1<<"                                                              \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                          \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

      cin>>user;
      system("cls");
      if(user=='e'){
        electrical_charge(num1,num2,ans1,operation,user);
      }
       if(user=='c'){
        capacitance(num1,num4,ans2,operation1,user);
      }
       if(user=='i'){
        current_voltage(num1,num4,ans3,operation2,user);
      }
       if(user=='p'){
        power(num1,num4,ans4,operation3,user);
      }

    }
    break;

case 6:
    {
fstream object;

    float area,perimeter,volume;
    rectangle box;
    int type,p;
    float radius;
    char history;
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                         Select the type of object to measure :                       \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Rectangles                                                \n";
    cout<<"       7  |  8  |  9  |  2. Circle                                                    \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> type;
    system("cls");

    if( type == 1)
    {
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                              Please insert the length :                              \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Rectangles                                                \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> box.length;
    system("cls");

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                              Please insert the height :                              \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Rectangles                                                \n";
    cout<<"       7  |  8  |  9  |     L ="<<box.length<<"\t\t                                   \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> box.height;
    system("cls");

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                              Please insert the width :                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Rectangles                                                \n";
    cout<<"       7  |  8  |  9  |     L ="<<box.length<<" H = "<<box.height<<"                  \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> box.width;
    system("pause");
        area = box.length * box.height;
        volume = box.length * box.height * box.width;
        perimeter = (box.length*2)+(box.height*2);

        system("cls");

        cout << "\n\n\n\t\t\tCalculating";
        for(int i=0; i<3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        system("cls");

        cout << endl;

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                        The perimeter is :" << perimeter <<"                          \n";
    cout<<"                        The area is :" << area <<"                                    \n";
    cout<<"                        The volume is " << volume <<"                                 \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Rectangles                                                \n";
    cout<<"       7  |  8  |  9  |     L = "<<box.length<<" H = "<<box.height<<" W ="<<box.width<<"\n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    }
    else if (type == 2)
    {
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                               Please insert the radius :                             \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  2. Circle                                                    \n";
    cout<<"       7  |  8  |  9  |                                                               \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> radius;
    system("cls");
        area = (pow(radius,2)) * 2.142;
        perimeter = 2 * 2.142 * radius;
        volume = 2.142 * (pow(radius,3)) * 4/3;

        cout << "\n\n\n\t\t\tCalculating";
        for(int i=0; i<3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        system("cls");
        cout << endl;
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                        The perimeter is :" << perimeter <<"                          \n";
    cout<<"                        The area is :" << area <<"                                    \n";
    cout<<"                        The volume is " << volume <<"                                 \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Type :                                                       \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |  1. Rectangles                                                \n";
    cout<<"       7  |  8  |  9  |     R = "<<radius<<"\t\t                                      \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    }
    object.open("MeasureObject.txt",ios::out|ios::app);
    object << perimeter <<endl;
    object << area << endl;
    object << volume << endl;
    object << endl;

    system("pause");
    system("cls");
    cout << "\n Do you want to view history? (Y for Yes,N for No): ";
    cin >> history;

    if(history == 'Y')
    {
        object >> perimeter;
        object >> area;
        object >> volume;

        cout << "\n Perimeter: " << perimeter << endl;
        cout << "\n Area: " << area << endl;
        cout << "\n Volume: " << volume << endl;
    }
    else if(history == 'N')
        cout << endl;
        object.close();
        system("pause");
        system("cls");
        main();
    }
    break;

case 7:
    {
    int x, y, z;

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                         Please enter the value of a, b and c:                        \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Quadratic equation                                           \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |                                                               \n";
    cout<<"       7  |  8  |  9  |                         ax^2+bx+c                             \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cin >> x >> y >> z;

    system("cls");

    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                                                                                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Quadratic equation                                           \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |                                                               \n";
    cout<<"       7  |  8  |  9  |                  "<<x<<"x^2+"<<y<<"x+"<<z<<"                  \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    cout << "Now this program will find its roots.... "<<endl;
    findRoot(x, y, z);
    }
    break;

case 8:
    {
        return 0;
    }
    }

}

void buat_tambah(float num1,float num2,float ans1,int operation, char user)
{


    if(user=='p')
    {
                    ofstream outputFile;
                    outputFile.open("Data1.txt",ofstream ::app);

    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" +                                                            \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                   \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num2;

    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" + "<<num2<<"                                              \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans1=num1+num2;

            system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" + "<<num2<<" = "<<ans1<<"                                                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";


                        outputFile << ans1 << endl;
                        cout << "Data have save to a Data1.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();

    }

}

void buat_tolak(float num1,float num4,float ans2,int operation1, char user)
{


    if(user=='m')
    {
                    ofstream outputFile;
                    outputFile.open("Data1.txt", ofstream::app);
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" -                                                            \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num4;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" - "<<num4<<"                                                 \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans2=num1-num4;

             system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" - "<<num4<<" = "<<ans2<<"                                                     \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";


                        outputFile << ans2 << endl;
                        cout << "Data have save to a Data1.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();
    }


}


void buat_darab(float num1,float num4,float ans3,int operation2, char user)
{


    if(user=='t')
    {
                    ofstream outputFile;
                    outputFile.open("Data1.txt", ofstream::app);
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" *                                                            \n";
    cout<<"     ________________________________________________________________________________\n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num4;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" * "<<num4<<"                                                 \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                    \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans3=num1*num4;

             system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" * "<<num4<<" = "<<ans3<<"                                                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

                        outputFile << ans3 << endl;
                        cout << "Data have save to a Data1.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();
    }


}

void buat_bahagi(float num1,float num4,float ans4,int operation3, char user)
{


    if(user=='d')
    {
                    ofstream outputFile;
                    outputFile.open("Data1.txt", ofstream::app);
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" /                                                            \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"       Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (t)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num4;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" / "<<num4<<"                                                 \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (d)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans4=num1/num4;

             system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" / "<<num4<<" = "<<ans4<<"                                                     \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |     + (p)                                                     \n";
    cout<<"       4  |  5  |  6  |     - (m)                                                     \n";
    cout<<"       7  |  8  |  9  |     * (d)                                                     \n";
    cout<<"          |  0  |     |     / (d)                                                     \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

                        outputFile << ans4 << endl;
                        cout << "Data have save to a Data1.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();
    }

}


void electrical_charge(float num1,float num2,float ans1,int operation, char user)
{


            if(user=='e'){
                    ofstream outputFile;
                    outputFile.open("Data5.txt", ofstream::app);

    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" *                                                            \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num2;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                     \n";
    cout<<"                  \t"<<num1<<" * "<<num2<<"                                             \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans1=num1*num2;

             system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                     | \n";
    cout<<"                  \t"<<num1<<" * "<<num2<<" = "<<ans1<<"                                                     | \n";
    cout<<"     ________________________________________________________________________________| \n";
    cout<<"      Number | Button |  Operation                                                   | \n";
    cout<<"     ________|________|______________________________________________________________| \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                          | \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                          | \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                          | \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                          | \n";
    cout<<"     _____|_____|_____|______________________________________________________________| \n";

                        outputFile << ans1 << endl;
                        cout << "Data have save to a Data5.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();

            }



        }

void capacitance(float num1,float num4,float ans2,int operation1, char user)
{


            if(user=='c'){
                    ofstream outputFile;
                    outputFile.open("Data5.txt", ofstream::app);
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" /                                                            \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num4;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" / "<<num4<<"                                             \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans2=num1/num4;

             system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" / "<<num4<<" = "<<ans2<<"                                                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                     \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                            \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                            \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                            \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                            \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

                        outputFile << ans2 << endl;
                        cout << "Data have save to a Data5.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();
            }

}


void current_voltage(float num1,float num4,float ans3,int operation2, char user)
{


            if(user=='i'){
                    ofstream outputFile;
                    outputFile.open("Data5.txt", ofstream::app);
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" /                                                            \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
          cin>>num4;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" / "<<num4<<"                                             \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            ans3=num1/num4;

             system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<" / "<<num4<<" = "<<ans3<<"                                                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

                        outputFile << ans3 << endl;
                        cout << "Data have save to a Data5.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();
            }


}

void power(float num1,float num4,float ans4,int operation3,char user)
{
int s;

            if(user=='p'){
                    ofstream outputFile;
                    outputFile.open("Data5.txt", ofstream::app);
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<"^2 *                                                          \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";
    cin>>num4;


    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<"^2 * "<<num4<<"                                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

            s=num1;
            ans4=pow(s,2);
            ans4=ans4*num4;

            system("CLS");
    cout<<"      ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                  \t"<<num1<<"^2 * "<<num4<<" = "<<ans4<<"                                                    \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |  (electrical charge)Q = I * t   (e)                           \n";
    cout<<"       4  |  5  |  6  |  (capacitance)C = Q / V         (c)                           \n";
    cout<<"       7  |  8  |  9  |  (current voltage) I = V / R    (i)                           \n";
    cout<<"          |  0  |     |  (power) P = I^2 * R            (p)                           \n";
    cout<<"     _____|_____|_____|______________________________________________________________ \n";

                        outputFile << ans4 << endl;
                        cout << "Data have save to a Data5.txt\n";
                        outputFile.close();
                        system("pause");
                        system("cls");
                        main();


 }
}

void findRoot(int x, int y, int z)
{
    fstream findroot;
    char history;

    findroot.open("Quadratic.txt",ios::out|ios::app);
   cout <<"Computing roots";
   for (int i=0;i<=5;i++)
   {
       cout<<".";
       Sleep(500);
   }
   cout << endl;
   float a;
   float root1, root2;
   a = pow(y,2)-4*x*z;
   if (a<0)
   {
       system("cls");
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                                There is no real root                                 \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Quadratic equation                                           \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |                                                               \n";
    cout<<"       7  |  8  |  9  |                 "<<x<<"x^2+"<<y<<"x+"<<z<<"                   \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    findroot.close();
   }

   if (a>0)
   {
        cout << "There are two real roots"<<endl;
        root1 = (-y+sqrt(a))/(2*x);
        root2 = (-y-sqrt(a))/(2*x);
        system("cls");
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                     The roots are : "<<root1<<" and "<<root2<<"                      \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Operation                                                    \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |                  Quadratic equation is:                       \n";
    cout<<"       7  |  8  |  9  |               "<<x<<"x^2+"<<y<<"x+"<<z<<"                     \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    findroot << root1 << endl;
    findroot << root2 << endl;
system("pause");
system("cls");
    cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history;
        if(history == 'Y'||history == 'y')
        {
            findroot >> root1;
            findroot >> root2;
            cout << "\n Root : " << root1 << "\tand : " << root2;
            system("pause");
            system("cls");
            main();
        }
        else if(history == 'N')
            cout << endl;
            findroot.close();
            system("pause");
            system("cls");
            main();
   }

   if (a==0)
   {
       cout <<"There is one real root"<<endl;
       root1 = (-y+a)/(2*x);
       system("cls");
    cout<<"     ________________________________________________________________________________\n";
    cout<<"                                                                                      \n";
    cout<<"                   There is one real root : "<<root1<<"                               \n";
    cout<<"     ________________________________________________________________________________ \n";
    cout<<"      Number | Button |  Quadratic equation                                           \n";
    cout<<"     ________|________|______________________________________________________________ \n";
    cout<<"       1  |  2  |  3  |                                                               \n";
    cout<<"       4  |  5  |  6  |                                                               \n";
    cout<<"       7  |  8  |  9  |                  "<<x<<"x^2+"<<y<<"x+"<<z<<"                  \n";
    cout<<"          |  0  |     |                                                               \n";
    cout<<"     ________________________________________________________________________________ \n";

    cout << "\n Do you want to view history? (Y for Yes,N for No): ";

        cin >> history;
        if(history == 'Y')
        {findroot >> root1;
            cout <<"the root is : "<<root1<<endl;
            system("pause");
            system("cls");
            main();

        }
        else if(history == 'N')
            cout << endl;
            findroot.close();
            system("pause");
            system("cls");
            main();
   }

}

# data[].attributes.body
report

# data[].attributes.body
coding

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <windows.h>
#define MAX 1000
#include<conio.h>
#include<math.h>
using namespace std;
unsigned long convtodecinum(char hex[]);
/*----------------------------------------funtion Prototype---------------------------------------------*/
//function prototype

struct question6
{

    float result;
};

const float PI=3.14159;             //pi
void getCircumference(float);         //circumference
void getAreaRec(float,float);           //Area rectangle
void getAreaCircle(float);            //Area Cicle
void getVolumeRec(float,float,float);     //Volume Rectangle
void getVolumeCircle(float);           //Volume Circle
void showQuestion1();               //choice1
void showQuestion2();
void showQuestion3();
void showQuestion4();               //choice4
void showQuestion5();               //choice5
void showQuestion6();               //choice6
void showQuestion7();               //choice7
void showQuestion();                //menu
void getValue(float,float,float);   //quadratic equation (b^2)-4ac
void getCharge1(int,int);           //charge1 Q=cv
void getCharge2(int,int);           //charge2 Q=it
void getCurrent1(float,float);      //current1 i=v/r
void getCurrent2(float,float);      //current2 i=P/v
void getCapacitance1(float);        //capacitance1 C=series
void getCapacitance2(float);        //capacitence2 C=parallel
void getVoltage1(float,float);      //Voltage1 V=ir
void getVoltage2(float,float);      //Voltage2 V=P/i
void getPower1(float,float);        //Power1 P=(i^2)/r
void getPower2(float,float);        //Power2 P=(v^2)/r
void getPower3(float,float);        //Power3 P=iV
void addition(int &);
void subtraction(int &);
void multiplication(int &);
void binary(int);
void db();
void dh();
void bd();
void bh();
void hd();
void hb();

/*----------------------------------------funtion declaration---------------------------------------------*/
/*--------------------------------------------main program------------------------------------------------*/

int main()      // cout/display for choice the expression from 1-7
{
    ifstream infile;
    infile.open("all.txt",fstream::app);
    int x=0;
    string z;
    while(x<1)
    {
        int choose;
        cout<<"****************************************************************"<<endl;
        cout<<"*\tThis program will develop an engineering calculator"<<endl<<endl;
        cout<<"*\t1. Addition,subtraction,multiplication and division\n\t   operation of scalar values"<<endl<<endl;
        cout<<"*\t2. Addition, subtraction and multiplication of matrices\n\t\t\t"<<endl;
        cout<<"*\t3. Conversion between Binary values, Hexadecimal \n\t   Values and Decimal Values\t\t"<<endl<<endl;
        cout<<"*\t4. Trigonometric operations such as finding cosine, \n\t   sine, tangent, cotangent, cosecant and secant"<<endl<<endl;
        cout<<"*\t5. Compute Electrical Charge, Capacitance, Current, \n\t   Voltages and Power."<<endl<<endl;
        cout<<"*\t6. Compute Perimeter/Circumference, Area and Volume of\n\t   rectangles and circles."<<endl<<endl;
        cout<<"*\t7. Solve roots of quadratic equations\n"<<endl;
        cout<<"*\t8. History\n"<<endl;
        cout<<"*\t9. Exit Calculator"<<endl;
        cout<<"****************************************************************"<<endl;
        cout<<"Your option: ";
        cin>>choose;

        switch(choose)              //make choice of the type expression of solution
        {
        case(1):                    //case1
            system("CLS");          //use CLS to clear the screen and open the showQuestion1
            showQuestion1();
            break;                  //break to stop the command for doing the case1

        case(2):
            system("cls");
            showQuestion2();
            break;

        case(3):
            system("cls");
            showQuestion3();
            break;


        case(4):
            system("CLS");
            showQuestion4();
            break;

        case(5):
            system("CLS");
            showQuestion5();
            break;

        case(6):
            system("CLS");
            showQuestion6();
            break;

        case(7):
            system("CLS");
            showQuestion7();
            break;

        case(8):
            system("cls");
            while(!infile.eof())
            {
                getline(infile,z);
                cout<<z<<endl;
            }
            system("pause");
            system("cls");
            break;

        case(9):
            x=1;
            break;

        default:
            system("cls");
            cout<<"Invalid.\nPlease try again.";
            Sleep(2000);
        }

    }
    return 0;
}

/*--------------------------------------------main program------------------------------------------------*/

/*--------------------------------------------call question------------------------------------------------*/

void showQuestion()    // to make choice of expression 1-7(menu)
{
    system("cls");
    int choose;
     cout<<"\t\n\n* This program will develop an engineering calculator"<<endl<<endl;
    cout<<"*\t1. Addition,subtraction,multiplication and division\n\t   operation of scalar values"<<endl<<endl;
    cout<<"*\t2. Addition, subtraction and multiplication of matrices\n\t\t\t"<<endl<<endl;
    cout<<"*\t3. Conversion between Binary values, Hexadecimal \n\t   Values and Decimal Values\t\t"<<endl<<endl;
    cout<<"*\t4. Trigonometric operations such as finding cosine, \n\t   sine, tangent, cotangent, cosecant and secant"<<endl<<endl;
    cout<<"*\t5. Compute Electrical Charge, Capacitance, Current, \n\t   Voltages and Power, given that required parameters are given by user"<<endl<<endl;
    cout<<"*\t6. Compute Perimeter/Circumference, Area and Volume of\n\t   rectangles and circles, given that required parameters are given by user"<<endl<<endl;
    cout<<"*\t7. Solve roots of quadratic equations"<<endl<<endl;
    cout<<"\nYour option: ";
    cin>>choose;

    while(1)
    {
        switch(choose)
        {
        case(1):
            system("CLS");
            showQuestion1();
            break;

        case(2):
            system("CLS");
            showQuestion2();
            break;

        case(3):
            system("CLS");
            showQuestion3();
            break;

        case(4):
            system("CLS");
            showQuestion4();
            break;
        case(5):
            system("CLS");
            showQuestion5();
            break;
        case(6):
            system("CLS");
            showQuestion6();
            break;
        case(7):
            system("CLS");
            showQuestion7();
            break;
        default:
            cout<<"Invalid";
        }
        cout<<"\nYour option: ";
        cin>>choose;
    }
}

/*--------------------------------------------call question------------------------------------------------*/

/*--------------------------------------------question 1------------------------------------------------*/

void showQuestion1()    //expression of number 1(additional, subtraction,multiplication,dividition)
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    int m=0;
    char q;
    while(m<1)
    {
        float x,y;
        int n=0,d=0;
        char z;
        cout<<"Operation of Scalar Values\n";
        cout<<"**************************\n\n";
        outFile<<"\nOperation of Scalar Values\n";
        outFile<<"**************************\n\n";
        cout<<"*Notice*\n";
        cout<<"Entering the value 0 or any other value than a scalar value\nwill exit to main menu.\n\n";
        system("pause");
        system("cls");
        while(d<1)
        {
            cout<<"Operation of Scalar Values\n";
            cout<<"**************************\n\n";
            cout<<"Enter two number with operation (+, -, *, /) in the middle.\n";
            cout<<"\nDesired Equation:\n";
            outFile<<"Enter two number with operation (+, -, *, /) in the middle.\n";
            outFile<<"\nDesired Equation:\n";
            cin>>x;
            outFile<<x;
            if(x==0)
            {
                d=1;
                m=1;
                n=1;
                system("cls");
                cout<<"Number zero entered.\nReturning to main menu.";     //result x/y
                outFile<<"\nNumber zero entered.\nReturning to main menu.\n";
                Sleep(1000);
                continue;
                continue;
            }
            cin>>z;
            outFile<<z;
            cin>>y;
            if(y==0)
            {
                d=1;
                m=1;
                n=1;
                system("cls");
                cout<<"Number zero entered.\nReturning to main menu.";     //result x/y
                outFile<<"\nNumber zero entered.\nReturning to main menu.\n";
                Sleep(1000);
                continue;
                continue;
            }
            outFile<<y<<endl;
            if((x==0)||(y==0))                //if user put /
            {
                d=1;
                m=1;
                n=1;
                system("cls");
                cout<<"Number zero entered.\nReturning to main menu.";     //result x/y
                outFile<<"\nNumber zero entered.\nReturning to main menu.\n";
                Sleep(1000);
            }
            else if(z=='+')                      //if user put +
            {
                d=1;
                cout<<"Result: "<<x+y;      //result x+y
                outFile<<"Result: "<<x+y<<endl;
                cout<<endl;
                outFile<<endl;
                system("pause");
                system("cls");
            }    //result x+y
            else if(z=='-')                 //if user put -
            {
                d=1;
                cout<<"Result: "<<x-y;
                outFile<<"Result: "<<x-y<<endl;
                cout<<endl;
                outFile<<endl;
                system("pause");
                system("cls");       //result x-y
            }      //result x-y
            else if(z=='*')                 //if user put *
            {
                d=1;
                cout<<"Result: "<<x*y;
                outFile<<"Result: "<<x*y<<endl;
                cout<<endl;
                outFile<<endl;
                system("pause");
                system("cls");      //result x*y
            }    //result x*y
            else if(z=='/')                 //if user put /
            {
                d=1;
                cout<<"Result: "<<x/y;
                outFile<<"Result: "<<x/y<<endl;
                cout<<endl;
                outFile<<endl;
                system("pause");
                system("cls");       //result x/y
            }     //result x/y
            else
            {
                system("cls");
                cout<<"Invalid operation\nPlease try again\n";
                outFile<<"\nInvalid operation\nPlease try again\n";
                Sleep(2000);
                system("cls");           //if else of symbol it will display error
            }
        }
                    //if else of symbol it will display error

        while(n<1)
        {
            cout<<"Operation of Scalar Values\n";
            cout<<"**************************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>q;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<q<<endl;
            if((q=='y')||(q=='Y'))
            {
                n=1;
                system("cls");
            }
            else if((q=='n')||(q=='N'))
            {
                n=1;
                m=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }
    }
    outFile.close();
}


/*--------------------------------------------question 2------------------------------------------------*/
void showQuestion2()
{
    int k=0;
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    while(k<3)
    {
        system("cls");
        int x;
        cout<<"Addition, Subtraction and Multiplication of Matrix\n";
        cout<<"****************************************************\n\n";
        cout<<"Please choose your operation:\n";
        cout<<"1. Addition\n";
        cout<<"2. Subtraction\n";
        cout<<"3. Multiplication\n";
        cout<<"4. Exit to main menu\n\n";
        cout<<"Your option: ";
        cin>>x;
        outFile<<"\nAddition, Subtraction and Multiplication of Matrix\n";
        outFile<<"****************************************************\n\n";
        outFile<<"Please choose your operation:\n";
        outFile<<"1. Addition\n";
        outFile<<"2. Subtraction\n";
        outFile<<"3. Multiplication\n";
        outFile<<"4. Exit to main menu\n\n";
        outFile<<"Your option: ";
        outFile<<x<<endl;
        switch (x)
        {
                case 1:
                    addition(k);
                    break;

                case 2:
                    subtraction(k);
                    break;

                case 3:
                    multiplication(k);
                    break;

                case 4:
                    k=4;
                    break;

                default:
                    system("cls");
                    cout<<"Invalid\nPlease try again.";
                    outFile<<"Invalid\nPlease try again.";
                    Sleep(2000);


        }


    }
    cout<<endl;
    outFile<<endl;
    outFile.close();
    system("cls");
}

void addition(int &k)
{
    k=0;
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    while(k<2)
    {
        system("cls");
        cout<<"Addition of Matrix\n";
        cout<<"******************\n\n";
        outFile<<"\nAddition of Matrix\n";
        outFile<<"******************\n\n";
        int matrix1[3][3];
        int matrix2[3][3];
        int sum[3][3]={0};
        int a,b,i,j,x,z=0;
        while(z<1)
        {
            cout<<"Please enter the number of rows and columns from 1 to 3.\n";
            cout<<"Enter the number of Row(s): ";
            cin>>a;
            cout<<"Enter the number of Column(s): ";
            cin>>b;
            outFile<<"Please enter the number of rows and columns from 1 to 3.\n";
            outFile<<"Enter the number of Row(s): ";
            outFile<<a<<endl;
            outFile<<"Enter the number of Column(s): ";
            outFile<<b<<endl;
            if((a>0&&a<4)&&(b>0&&b<4))
                z=1;
            else
            {
                system("cls");
                cout<<"Invalid\nPlease try again.";
                outFile<<"\nInvalid\nPlease try again.";
                Sleep(2000);
                system("cls");
            }
        }
        system("cls");
        cout<<"Enter elements of first Matrix:\n\n";
        outFile<<"\nEnter elements of first Matrix:\n\n";
        for(i = 0; i < a; ++i)
        for(j = 0; j < b; ++j)
        {
            cout<<setw(5) << "a" << i + 1 << j + 1 ;
            outFile<<setw(5) << "a" << i + 1 << j + 1 ;
            if(j == b - 1)
            {
                    cout << endl;
                    outFile << endl;
            }
        }
        cout<<"\n\n";
        outFile<<"\n\n";
        for(i=0;i<a;++i)
            for(j=0;j<b;++j)
            {
                cout<< "Enter element a" << i + 1 << j + 1 << " : ";
                cin>>matrix1[i][j];
                outFile<< "Enter element a" << i + 1 << j + 1 << " : ";
                outFile<<matrix1[i][j]<<endl;
            }
        system("cls");
        for(i=0;i<a;++i)
            for(j=0;j<b;++j)
                sum[i][j]= matrix1[i][j];
        k=0;
        while(k<1)
        {
            system("cls");
            cout<<"Your first matrix:\n\n";
            outFile<<"\nYour first matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout<<setw(5) << sum[i][j] ;
                    outFile<<setw(5) << sum[i][j] ;
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile<<endl;
                    }
                }
            cout<<endl;
            outFile<<endl;
            system("pause");
            system("cls");
            cout<<"\nEnter elements of second Matrix:\n\n";
            outFile<<"\nEnter elements of second Matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout <<setw(5) << "b" << i + 1 << j + 1;
                    outFile<<setw(5) << "b" << i + 1 << j + 1 ;
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile << endl;
                    }
                }
            cout<<"\n\n";
            outFile<<"\n\n";
            for(i=0;i<a;++i)
                for(j=0;j<b;++j)
                {
                    cout<< "Enter element b" << i + 1 << j + 1 << " : ";
                    cin>>matrix2[i][j];
                    outFile<< "Enter element b" << i + 1 << j + 1 << " : ";
                    outFile<<matrix2[i][j]<<endl;
                }
            system("cls");
            cout<<"Your second matrix:\n\n";
            outFile<<"\nYour second matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout <<setw(5) << matrix2[i][j];
                    outFile <<setw(5) << matrix2[i][j];
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile << endl;
                    }

                }
            cout<<endl;
            outFile<<endl;
            system("pause");
            system("cls");
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                    sum[i][j]+= matrix2[i][j];

            cout << "Sum of two matrix is: \n" << endl;
            outFile << "\nSum of two matrix is: \n" << endl;
            for(i = 0; i < a; ++i)
                for(j=0;j<b; ++j)
                {
                    cout<<setw(5)<<sum[i][j];
                    outFile<<setw(5)<<sum[i][j];
                    if(j==b-1)
                    {
                        cout<<endl;
                        outFile<<endl;
                    }
                }
            system("pause");
            int y=0;
            while(y<1)
            {
                system("cls");
                cout<<"Do you wish to:\n";
                cout<<"1. Continue this operation with current matrix.\n";
                cout<<"2. Continue this operation with new matrix.\n";
                cout<<"3. Return to sub-menu.\n";
                cout<<"4. Return to main-menu.\n\n";
                cout<<"Your option: ";
                cin>>x;
                outFile<<"\nDo you wish to:\n";
                outFile<<"1. Continue this operation with current matrix.\n";
                outFile<<"2. Continue this operation with new matrix.\n";
                outFile<<"3. Return to sub-menu.\n";
                outFile<<"4. Return to main-menu.\n\n";
                outFile<<"Your option: ";
                outFile<<x<<endl;
                switch (x)
                {
                    case 1:
                    k=0;
                    y=1;
                    break;

                    case 2:
                    k=1;
                    y=1;
                    break;

                    case 3:
                    k=2;
                    y=1;
                    break;

                    case 4:
                    k=3;
                    y=1;
                    break;

                    default:
                    system("cls");
                    cout<<"Invalid.\nPlease try again.";
                    outFile<<"\nInvalid.\nPlease try again.";
                    Sleep(2000);
                }

            }
        }
    }
    outFile.close();

}

void subtraction(int &k)
{
    k=0;
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    while(k<2)
    {
        system("cls");
        cout<<"Subtraction of Matrix\n";
        cout<<"*********************\n\n";
        outFile<<"\nSubtraction of Matrix\n";
        outFile<<"*********************\n\n";
        int matrix1[3][3];
        int matrix2[3][3];
        int sum[3][3]={0};
        int a,b,i,j,x,z=0;
        while(z<1)
        {
            cout<<"Please enter the number of rows and columns from 1 to 3.\n";
            cout<<"Enter the number of Row(s): ";
            cin>>a;
            cout<<"Enter the number of Column(s): ";
            cin>>b;
            outFile<<"Please enter the number of rows and columns from 1 to 3.\n";
            outFile<<"Enter the number of Row(s): ";
            outFile<<a<<endl;
            outFile<<"Enter the number of Column(s): ";
            outFile<<b<<endl;
            if((a>0&&a<4)&&(b>0&&b<4))
                z=1;
            else
            {
                system("cls");
                cout<<"Invalid\nPlease try again.";
                outFile<<"\nInvalid\nPlease try again.";
                Sleep(2000);
                system("cls");
            }
        }
        system("cls");
        cout<<"Enter elements of first Matrix:\n\n";
        outFile<<"\nEnter elements of first Matrix:\n\n";
        for(i = 0; i < a; ++i)
        for(j = 0; j < b; ++j)
        {
            cout<<setw(5) << "a" << i + 1 << j + 1 ;
            outFile<<setw(5) << "a" << i + 1 << j + 1 ;
            if(j == b - 1)
            {
                    cout << endl;
                    outFile << endl;
            }
        }
        cout<<"\n\n";
        outFile<<"\n\n";
        for(i=0;i<a;++i)
            for(j=0;j<b;++j)
            {
                cout<< "Enter element a" << i + 1 << j + 1 << " : ";
                cin>>matrix1[i][j];
                outFile<< "Enter element a" << i + 1 << j + 1 << " : ";
                outFile<<matrix1[i][j]<<endl;
            }
        system("cls");
        for(i=0;i<a;++i)
            for(j=0;j<b;++j)
                sum[i][j]= matrix1[i][j];
        k=0;
        while(k<1)
        {
            system("cls");
            cout<<"Your first matrix:\n\n";
            outFile<<"\nYour first matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout<<setw(5) << sum[i][j] ;
                    outFile<<setw(5) << sum[i][j] ;
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile<<endl;
                    }
                }
            cout<<endl;
            outFile<<endl;
            system("pause");
            system("cls");
            cout<<"\nEnter elements of second Matrix:\n\n";
            outFile<<"\nEnter elements of second Matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout <<setw(5) << "b" << i + 1 << j + 1;
                    outFile<<setw(5) << "b" << i + 1 << j + 1 ;
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile << endl;
                    }
                }
            cout<<"\n\n";
            outFile<<"\n\n";
            for(i=0;i<a;++i)
                for(j=0;j<b;++j)
                {
                    cout<< "Enter element b" << i + 1 << j + 1 << " : ";
                    cin>>matrix2[i][j];
                    outFile<< "Enter element b" << i + 1 << j + 1 << " : ";
                    outFile<<matrix2[i][j]<<endl;
                }
            system("cls");
            cout<<"Your second matrix:\n\n";
            outFile<<"\nYour second matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout <<setw(5) << matrix2[i][j];
                    outFile <<setw(5) << matrix2[i][j];
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile << endl;
                    }

                }
            cout<<endl;
            outFile<<endl;
            system("pause");
            system("cls");
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                    sum[i][j]-= matrix2[i][j];

            cout << "Subtraction of two matrix is: \n" << endl;
            outFile << "\nSubtraction of two matrix is: \n" << endl;
            for(i = 0; i < a; ++i)
                for(j=0;j<b; ++j)
                {
                    cout<<setw(5)<<sum[i][j];
                    outFile<<setw(5)<<sum[i][j];
                    if(j==b-1)
                    {
                        cout<<endl;
                        outFile<<endl;
                    }
                }
            system("pause");
            int y=0;
            while(y<1)
            {
                system("cls");
                cout<<"Do you wish to:\n";
                cout<<"1. Continue this operation with current matrix.\n";
                cout<<"2. Continue this operation with new matrix.\n";
                cout<<"3. Return to sub-menu.\n";
                cout<<"4. Return to main-menu.\n\n";
                cout<<"Your option: ";
                cin>>x;
                outFile<<"\nDo you wish to:\n";
                outFile<<"1. Continue this operation with current matrix.\n";
                outFile<<"2. Continue this operation with new matrix.\n";
                outFile<<"3. Return to sub-menu.\n";
                outFile<<"4. Return to main-menu.\n\n";
                outFile<<"Your option: ";
                outFile<<x<<endl;
                switch (x)
                {
                    case 1:
                    k=0;
                    y=1;
                    break;

                    case 2:
                    k=1;
                    y=1;
                    break;

                    case 3:
                    k=2;
                    y=1;
                    break;

                    case 4:
                    k=3;
                    y=1;
                    break;

                    default:
                    system("cls");
                    cout<<"Invalid.\nPlease try again.";
                    outFile<<"\nInvalid.\nPlease try again.";
                    Sleep(2000);
                }

            }
        }
    }
    outFile.close();

}

void multiplication(int &k)
{
    k=0;
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    while(k<2)
    {
        system("cls");
        cout<<"Multiplication of Matrix\n";
        cout<<"************************\n\n";
        outFile<<"\nMultiplication of Matrix\n";
        outFile<<"************************\n\n";
        int matrix1[3][3];
        int matrix2[3][3];
        int multiply[3][3]={0};
        int a,b,c,d,i,j,x,q,z=0;
        cout<<"Please enter the number of rows and columns from 1 to 3 for both matrix\n\n";
        outFile<<"Please enter the number of rows and columns from 1 to 3 for both matrix\n\n";
        while(z<1)
        {
            cout<<"Enter row and column for 1st Matrix(1-3)\n";
            cout<<"Enter the number of Row(s): ";
            cin>>a;
            cout<<"Enter the number of Column(s): ";
            cin>>b;
            outFile<<"Enter row and column for 1st Matrix(1-3)\n";
            outFile<<"Enter the number of Row(s): ";
            outFile<<a<<endl;
            outFile<<"Enter the number of Column(s): ";
            outFile<<b<<endl;;
            if((a>0&&a<4)&&(b>0&&b<4))
                z=1;
            else
            {
                system("cls");
                cout<<"Invalid\nPlease try again.";
                outFile<<"\nInvalid\nPlease try again.";
                Sleep(2000);
                system("cls");
            }
        }
        system("cls");
        cout<<"Enter elements of first Matrix:\n\n";
        outFile<<"\nEnter elements of first Matrix:\n\n";
        for(i = 0; i < a; ++i)
        for(j = 0; j < b; ++j)
        {
            cout<<setw(5) << "a" << i + 1 << j + 1 ;
            outFile<<setw(5) << "a" << i + 1 << j + 1 ;
            if(j == b - 1)
            {
                    cout << endl;
                    outFile << endl;
            }
        }
        cout<<"\n\n";
        outFile<<"\n\n";
        for(i=0;i<a;++i)
            for(j=0;j<b;++j)
            {
                cout<< "Enter element a" << i + 1 << j + 1 << " : ";
                outFile<< "Enter element a" << i + 1 << j + 1 << " : ";
                cin>>matrix1[i][j];
                outFile<<matrix1[i][j]<<endl;
            }
        system("cls");
        k=0;
        while(k<1)
        {
            system("cls");
            cout<<"Your first matrix:\n\n";
            outFile<<"\nYour first matrix:\n\n";
            for(i = 0; i < a; ++i)
                for(j = 0; j < b; ++j)
                {
                    cout<<setw(5) << matrix1[i][j] ;
                    outFile<<setw(5) << matrix1[i][j] ;
                    if(j == b - 1)
                    {
                        cout << endl;
                        outFile << endl;
                    }
                }
            cout<<endl;
            outFile<<endl;
            system("pause");
            system("cls");
            int n=0;
            while(n<1)
            {
                cout<<"Enter row and column for 2nd Matrix(1-3)\n";
                cout<<"Enter the number of Row(s): ";
                cin>>c;
                cout<<"Enter the number of Column(s): ";
                cin>>d;
                outFile<<"\nEnter row and column for 2nd Matrix(1-3)\n";
                outFile<<"Enter the number of Row(s): ";
                outFile<<c<<endl;
                outFile<<"Enter the number of Column(s): ";
                outFile<<d;

                if((c>0&&c<4)&&(d>0&&d<4))
                    n=1;
                else
                {
                    system("cls");
                    cout<<"Invalid\nPlease try again.";
                    outFile<"\nInvalid\nPlease try again.";
                    Sleep(2000);
                    system("cls");
                }
            }
            while(b!=c)
            {
                system("cls");
                cout<<"Error! Column of first matrix does not equal to row of second matrix!\nTry again!";
                outFile<<"\nError! Column of first matrix does not equal to row of second matrix!\nTry again!";
                Sleep(2000);
                system("cls");
                n=0;
                while(n<1)
                {
                    cout<<"Enter row and column for 2nd Matrix(1-3)\n";
                    cout<<"Enter the number of Row(s): ";
                    cin>>c;
                    cout<<"Enter the number of Column(s): ";
                    cin>>d;
                    outFile<<"\nEnter row and column for 2nd Matrix(1-3)\n";
                    outFile<<"Enter the number of Row(s): ";
                    outFile<<c<<endl;
                    outFile<<"Enter the number of Column(s): ";
                    outFile<<d<<endl;

                    if((c>0&&c<4)&&(d>0&&d<4))
                        n=1;
                    else
                    {
                        system("cls");
                        cout<<"Invalid\nPlease try again.";
                        outFile<<"\nInvalid\nPlease try again.";
                        Sleep(2000);
                        system("cls");
                    }
                }
            }
            system("cls");
            cout<<"Enter elements of second Matrix:\n\n";
            outFile<<"\nEnter elements of second Matrix:\n\n";
            for(i = 0; i < c; ++i)
                for(j = 0; j < d; ++j)
                {
                    cout <<setw(5) << "b" << i + 1 << j + 1;
                    outFile <<setw(5) << "b" << i + 1 << j + 1;
                    if(j == d - 1){
                        cout << endl;
                        outFile << endl;
                    }
                }
            cout<<"\n\n";
            outFile<<"\n\n";
            for(i=0;i<c;++i)
                for(j=0;j<d;++j)
                {
                    cout<< "Enter element b" << i + 1 << j + 1 << " : ";
                    cin>>matrix2[i][j];
                    outFile<< "Enter element b" << i + 1 << j + 1 << " : ";
                    outFile<<matrix2[i][j]<<endl;
                }
            system("cls");
            cout<<"Your second matrix:\n\n";
            outFile<<"\nYour second matrix:\n\n";
            for(i = 0; i < c; ++i)
                for(j = 0; j < d; ++j)
                {
                    cout <<setw(5) << matrix2[i][j];
                    outFile <<setw(5) << matrix2[i][j];
                    if(j == d - 1){
                        cout << endl;
                        outFile << endl;
                    }

                }
            cout<<endl;
            outFile<<endl;
            system("pause");
            system("cls");
            for(i = 0; i < a; ++i)
                for(j = 0; j < d; ++j)
                {
                    multiply[i][j]=0;
                }
            for(i = 0; i < a; ++i)
                for(j = 0; j < d; ++j)
                    for(q = 0; q < c; ++q)
            {
                multiply[i][j] += matrix1[i][q] * matrix2[q][j];
            }
            cout << "Multiplication of two matrix is: \n" << endl;
            outFile << "\nMultiplication of two matrix is: \n" << endl;
            for(i = 0; i < a; ++i)
                for(j=0;j<d; ++j)
                {
                    cout<<setw(5)<<multiply[i][j];
                    outFile<<setw(5)<<multiply[i][j];
                    if(j==d-1)
                    {
                        cout<<endl;
                        outFile<<endl;
                    }
                }
            system("pause");
            int y=0;
            while(y<1)
            {
                system("cls");
                cout<<"Do you wish to:\n";
                cout<<"1. Continue this operation with current matrix.\n";
                cout<<"2. Continue this operation with new matrix.\n";
                cout<<"3. Return to sub-menu.\n";
                cout<<"4. Return to main-menu.\n\n";
                cout<<"Your option: ";
                cin>>x;
                outFile<<"Do you wish to:\n";
                outFile<<"1. Continue this operation with current matrix.\n";
                outFile<<"2. Continue this operation with new matrix.\n";
                outFile<<"3. Return to sub-menu.\n";
                outFile<<"4. Return to main-menu.\n\n";
                outFile<<"Your option: ";
                outFile<<x<<endl;

                switch (x)
                {
                    case 1:
                    for(i = 0; i < a; ++i)
                        for(j = 0; j < d; ++j)
                        {
                            matrix1[i][j]=multiply[i][j];
                        }
                    b=d;
                    k=0;
                    y=1;
                    break;

                    case 2:
                    k=1;
                    y=1;
                    break;

                    case 3:
                    k=2;
                    y=1;
                    break;

                    case 4:
                    k=3;
                    y=1;
                    break;

                    default:
                    system("cls");
                    cout<<"Invalid.\nPlease try again.";
                    outFile<<"\nInvalid.\nPlease try again.";
                    Sleep(2000);
                }

            }
        }
    }
    outFile.close();
}/*question 3*/
void showQuestion3()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    int p=0;
    int m;
    while(p<1)
    {
        cout<<"Conversion between Binary values, Hexadecimal Values and Decimal Values\n";
        cout<<"***********************************************************************\n\n";
        cout<<"Please choose your desired conversion:\n";
        cout<<"1. Decimal --> Binary\n";
        cout<<"2. Decimal --> Hexadecimal\n";
        cout<<"3. Binary --> Decimal\n";
        cout<<"4. Binary --> Hexadecimal\n";
        cout<<"5. Hexadecimal --> Decimal\n";
        cout<<"6. Hexadecimal --> Binary\n";
        cout<<"7. Exit to main menu\n";
        cout<<"\nYour option: ";
        cin>>m;
        outFile<<"\nConversion between Binary values, Hexadecimal Values and Decimal Values\n";
        outFile<<"***********************************************************************\n\n";
        outFile<<"Please choose your desired conversion:\n";
        outFile<<"1. Decimal --> Binary\n";
        outFile<<"2. Decimal --> Hexadecimal\n";
        outFile<<"3. Binary --> Decimal\n";
        outFile<<"4. Binary --> Hexadecimal\n";
        outFile<<"5. Hexadecimal --> Decimal\n";
        outFile<<"6. Hexadecimal --> Binary\n";
        outFile<<"7. Exit to main menu\n";
        outFile<<"\nYour option: ";
        outFile<<m<<endl;
        switch (m)
        {
            case 1:
                system("cls");
                db();
                break;

            case 2:
                system("cls");
                dh();
                break;

            case 3:
                system("cls");
                bd();
                break;

            case 4:
                system("cls");
                bh();
                break;

            case 5:
                system("cls");
                hd();
                break;

            case 6:
                system("cls");
                hb();
                break;

            case 7:
                p=1;
                break;

            default:
                system("cls");
                cout<<"Invalid.\nPlease try again.";
                outFile<<"\nInvalid.\nPlease try again.";
                Sleep(2000);

        }
        system("cls");
    }
    outFile.close();

}

void binary(int num)
{
    int rem;
    ofstream outFile;
    outFile.open("all.txt",fstream::app);

    if (num <= 1)
    {
        cout << num;
        outFile << num;
        return;
    }
    rem = num % 2;
    binary(num / 2);
    cout << rem;
    outFile << rem;
    outFile.close();
}

void db()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    char ch;
    int x=0;
    while(x<1)
    {
        int z=0,y=0;
        while (z<1)
        {
            int dec, bin;
            cout<<"Decimal --> Binary\n";
            cout<<"******************\n\n";
            cout << "Enter decimal number : ";
            cin >> dec;
            outFile<<"Decimal --> Binary\n";
            outFile<<"******************\n\n";
            outFile<< "Enter decimal number : ";
            outFile<< dec<<endl;
            system("cls");
            if (dec < 0)
            {
                cout << dec << " is not a positive integer." << endl;
                cout<<"Please try again.\n";
                outFile<<endl<< dec << " is not a positive integer." << endl;
                outFile<<"Please try again.\n";
                Sleep(2000);
                system("cls");
            }
            else
            {

                cout<<"Decimal --> Binary\n";
                cout<<"******************\n\n";
                cout << "The binary form of " << dec << " is ";
                outFile<< "\nThe binary form of " << dec << " is ";
                binary(dec);
                cout<<endl;
                outFile<<endl;
                system("pause");
                system("cls");
                z=1;
            }
        }
        while(y<1)
        {
            cout<<"Decimal --> Binary\n";
            cout<<"******************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>ch;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<ch<<endl;
            if((ch=='y')||(ch=='Y'))
            {
                y=1;
                system("cls");
            }
            else if((ch=='n')||(ch=='N'))
            {
                y=1;
                x=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }
    }
    outFile.close();
}

void dh()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    char ch;
    int x=0;
    while(x<1)
    {
        long int decimalNumber,remainder,quotient;
        int i=1,y=0,j,temp;
        char hexadecimalNumber[100];
        cout<<"Decimal --> Hexadecimal\n";
        cout<<"***********************\n\n";
        cout<<"Enter any decimal number: ";
        cin>>decimalNumber;
        outFile<<"\nDecimal --> Hexadecimal\n";
        outFile<<"***********************\n\n";
        outFile<<"Enter any decimal number: ";
        outFile<<decimalNumber<<endl;
        system("cls");

        quotient = decimalNumber;

        while(quotient!=0)
        {
             temp = quotient % 16;

          //To convert integer into character
          if( temp < 10)
               temp =temp + 48;
          else
             temp = temp + 55;

          hexadecimalNumber[i++]= temp;
          quotient = quotient / 16;
        }
        cout<<"Decimal --> Hexadecimal\n";
        cout<<"***********************\n\n";
        cout<<"Equivalent hexadecimal number of "<<decimalNumber<<" is : ";
        outFile<<"\nEquivalent hexadecimal number of "<<decimalNumber<<" is : ";
        for(j = i -1 ;j> 0;j--)
          cout<<hexadecimalNumber[j];
          outFile<<hexadecimalNumber[j];
        cout<<endl;
        outFile<<endl;
        system("pause");
        system("cls");
        while(y<1)
        {
            cout<<"Decimal --> Hexadecimal\n";
            cout<<"***********************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>ch;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<ch<<endl;
            if((ch=='y')||(ch=='Y'))
            {
                y=1;
                system("cls");
            }
            else if((ch=='n')||(ch=='N'))
            {
                y=1;
                x=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }
    }
    outFile.close();

}

void bd()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    char ch;
    int x=0;
    while(x<1)
    {
        int y=0;
        long bin, dec = 0, rem, num, base = 1;
        cout<<"Binary --> Decimal\n";
        cout<<"******************\n\n";
        cout << "Enter the binary number(1s and 0s) : ";
        cin >> num;
        outFile<<"\nBinary --> Decimal\n";
        outFile<<"******************\n\n";
        outFile<< "Enter the binary number(1s and 0s) : ";
        outFile<< num<<endl;
        bin = num;
        while (num > 0)
        {
            rem = num % 10;
            dec = dec + rem * base;
            base = base * 2;
            num = num / 10;
        }
        system("cls");
        cout<<"Binary --> Decimal\n";
        cout<<"******************\n\n";
        cout << "The decimal equivalent of " << bin << " : " << dec << endl;
        outFile << "\nThe decimal equivalent of " << bin << " : " << dec << endl;
        system("pause");
        system("cls");
        while(y<1)
        {
            cout<<"Binary --> Decimal\n";
            cout<<"******************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>ch;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<ch<<endl;
            if((ch=='y')||(ch=='Y'))
            {
                y=1;
                system("cls");
            }
            else if((ch=='n')||(ch=='N'))
            {
                y=1;
                x=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }
    }
    outFile.close();
}

void bh()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    char ch;
    int x=0;
    while(x<1)
    {
        char binnum[MAX], hexa[MAX];
        int temp,y=0;
        long int i=0,j=0;
        cout<<"Binary --> Hexadecimal\n";
        cout<<"**********************\n\n";
        cout<<"Enter Binary Number : ";
        cin>>binnum;
        outFile<<"\nBinary --> Hexadecimal\n";
        outFile<<"**********************\n\n";
        outFile<<"Enter Binary Number : ";
        outFile<<binnum<<endl;
        system("cls");
        while(binnum[i])
        {
                binnum[i] = binnum[i] -48;
                ++i;
        }
        --i;
        while(i-2>=0)
        {
                temp =  binnum[i-3] *8 + binnum[i-2] *4 +  binnum[i-1] *2 + binnum[i] ;
                if(temp > 9)
                        hexa[j++] = temp + 55;
                else
                        hexa[j++] = temp + 48;
                i=i-4;
        }
        if(i ==1)
                hexa[j] = binnum[i-1] *2 + binnum[i] + 48 ;
        else if(i==0)
                hexa[j] =  binnum[i] + 48 ;
        else
                --j;
        cout<<"Binary --> Hexadecimal\n";
        cout<<"**********************\n\n";
        cout<<"Binary Number to Hexadecimal Number : ";
        outFile<<"\nBinary Number to Hexadecimal Number : ";
        while(j>=0)
        {
                cout<<hexa[j--];
                outFile<<hexa[j--];
        }
        cout<<endl;
        outFile<<endl;
        system("pause");
        system("cls");
        while(y<1)
        {
            cout<<"Binary --> Hexadecimal\n";
            cout<<"**********************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>ch;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<ch<<endl;
            if((ch=='y')||(ch=='Y'))
            {
                y=1;
                system("cls");
            }
            else if((ch=='n')||(ch=='N'))
            {
                y=1;
                x=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }
    }
    outFile.close();

}

void hd()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    char ch;
    int x=0;
    while(x<1)
    {
        int y=0;
        unsigned long decinum;
        char hexa[9];  //8 characters for 32-bit Hexadecimal Number and one for ' '
        cout<<"Binary --> Hexadecimal\n";
        cout<<"**********************\n\n";
        cout<<"\n Enter Hexadecimal Number : ";
        cin>>hexa;
        outFile<<"\nBinary --> Hexadecimal\n";
        outFile<<"**********************\n\n";
        outFile<<"\n Enter Hexadecimal Number : ";
        outFile<<hexa<<endl;
        system("cls");
        decinum = convtodecinum(hexa);
        cout<<"Binary --> Hexadecimal\n";
        cout<<"**********************\n\n";
        cout<<"\n Decimal Number is : "<<decinum<<"\n";
        outFile<<"\n Decimal Number is : "<<decinum<<"\n";
        system("pause");
        system("cls");
        while(y<1)
        {
            cout<<"Binary --> Hexadecimal\n";
            cout<<"**********************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>ch;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<ch<<endl;
            if((ch=='y')||(ch=='Y'))
            {
                y=1;
                system("cls");
            }
            else if((ch=='n')||(ch=='N'))
            {
                y=1;
                x=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }

    }

}

unsigned long convtodecinum(char hexa[])
{
        char *hexastr;
        int length = 0;
        const int base = 16;     // Base of Hexadecimal Number
        unsigned long decinum = 0;
        int i;

        for (hexastr = hexa; *hexastr != '\0'; hexastr++)  // Finds the length of Hexadecimal Number
        {
                length++;
        }

        hexastr = hexa;  // Now Find Hexadecimal Number
        for (i = 0; *hexastr != '\0' && i < length; i++, hexastr++)
        {
                // Compares *hexastr with ASCII values
                if (*hexastr >= 48 && *hexastr <= 57)   //*hexastr Between 0-9
                {
                        decinum += (((int)(*hexastr)) - 48) * pow(base, length - i - 1);
                }
                else if ((*hexastr >= 65 && *hexastr <= 70))   //*hexastr Between A-F
                {
                        decinum += (((int)(*hexastr)) - 55) * pow(base, length - i - 1);
                }
                else if (*hexastr >= 97 && *hexastr <= 102)   //*hexastr Between a-f
                {
                        decinum += (((int)(*hexastr)) - 87) * pow(base, length - i - 1);
                }
                else
                {
                        cout<<"\n Invalid Hexadecimal Number...";
                }
        }
        return decinum;
}

void hb()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    char ch;
    int x=0;
    while(x<1)
    {

        char binaryNumber[MAX],hexaDecimal[MAX];
        long int i=0;
        int y=0;
        cout<<"Hexadecimal --> Binary\n";
        cout<<"**********************\n\n";
        cout<<"Enter any hexadecimal number: ";
        cin>>hexaDecimal;
        outFile<<"Hexadecimal --> Binary\n";
        outFile<<"**********************\n\n";
        outFile<<"Enter any hexadecimal number: ";
        outFile<<hexaDecimal<<endl;
        system("cls");
        cout<<"Hexadecimal --> Binary\n";
        cout<<"**********************\n\n";
        cout<<"Equivalent binary value: ";
        outFile<<"Equivalent binary value: ";
        while(hexaDecimal[i])
        {
             switch(hexaDecimal[i])
             {
                 case '0': cout<<"0000";outFile<<"0000";break;
                 case '1': cout<<"0001";outFile<<"0001"; break;
                 case '2': cout<<"0010";outFile<<"0010"; break;
                 case '3': cout<<"0011";outFile<<"0011"; break;
                 case '4': cout<<"0100";outFile<<"0100"; break;
                 case '5': cout<<"0101";outFile<<"0101"; break;
                 case '6': cout<<"0110";outFile<<"0110"; break;
                 case '7': cout<<"0111";outFile<<"0111"; break;
                 case '8': cout<<"1000";outFile<<"1000"; break;
                 case '9': cout<<"1001";outFile<<"1001"; break;
                 case 'A': cout<<"1010";outFile<<"1010"; break;
                 case 'B': cout<<"1011";outFile<<"1011"; break;
                 case 'C': cout<<"1100";outFile<<"1100"; break;
                 case 'D': cout<<"1101";outFile<<"1101"; break;
                 case 'E': cout<<"1110";outFile<<"1110"; break;
                 case 'F': cout<<"1111";outFile<<"1111"; break;
                 case 'a': cout<<"1010";outFile<<"1010"; break;
                 case 'b': cout<<"1011";outFile<<"1011"; break;
                 case 'c': cout<<"1100";outFile<<"1100"; break;
                 case 'd': cout<<"1101";outFile<<"1101"; break;
                 case 'e': cout<<"1110";outFile<<"1110"; break;
                 case 'f': cout<<"1111";outFile<<"1111"; break;
                 default:  cout<<"\nInvalid hexadecimal digit "<<hexaDecimal[i];outFile<<"\n\nInvalid hexadecimal digit "<<hexaDecimal[i];
             }
             i++;
        }
        cout<<endl;
        outFile<<endl;
        system("pause");
        system("cls");
        while(y<1)
        {
            cout<<"Binary --> Hexadecimal\n";
            cout<<"**********************\n\n";
            cout<<"Do you wish to continue (y/n): ";
            cin>>ch;
            outFile<<"\nDo you wish to continue (y/n): ";
            outFile<<ch<<endl;
            if((ch=='y')||(ch=='Y'))
            {
                y=1;
                system("cls");
            }
            else if((ch=='n')||(ch=='N'))
            {
                y=1;
                x=1;
                system("cls");
            }
            else
            {
                system("cls");
                cout<<"Invalid input\nPlease try again\n";
                outFile<<"\nInvalid input\nPlease try again\n";
                Sleep(2000);
                system("cls");
            }
        }
    }
    outFile.close();

}


/*--------------------------------------------question 4------------------------------------------------*/

void showQuestion4()  //expression of Trigonometric operations
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    int z=0;
    while(z<1)
    {
        float x,result;
        int pick;
        cout<<"Trigonometric Operations\n";
        cout<<"************************\n\n";
        outFile<<"Trigonometric Operations\n";
        outFile<<"************************\n\n";
        cout<<"Please enter the value(in degree) you wish to use: ";
        outFile<<"\nPlease enter the value(in degree) you wish to use: ";
        cin>>x;
        outFile<<x<<endl;
        x*=(PI/180);

        cout<<"\n1. cos(x)"<<"\n2. sin(x)"<<"\n3. tan(x)"<<"\n4. cot(x)"<<"\n5. cosec(x)"<<"\n6. sec(x)\n7. Exit to main menu\n";
        cout<<"\nPlease choose your option(1-6). Other than that will back to main menu.";
        cout<<"\nYour option: ";
        cin>>pick;
        outFile<<"\n1. cos(x)"<<"\n2. sin(x)"<<"\n3. tan(x)"<<"\n4. cot(x)"<<"\n5. cosec(x)"<<"\n6. sec(x)\n7. Exit to main menu\n";
        outFile<<"\nPlease choose your option(1-6). Other than that will back to main menu.";
        outFile<<"\nYour option: ";
        outFile<<pick<<endl;

        switch(pick)
        {
        case (1):
            result=cos(x);                                  //at case1 use cos(input from user =x)
            cout<<"Your result: "<<result<<endl;
            outFile<<"Your result: "<<result<<endl;
            system("pause");     //the result in radian
            break;
        case (2):
            result=sin(x);                                  //case2 use sin
            cout<<"Your result: "<<result<<endl;
            outFile<<"Your result: "<<result<<endl;
            system("pause");
            break;
        case (3):
            result=tan(x);                                  //case3 use tan
            cout<<"Your result: "<<result<<endl;
            outFile<<"Your result: "<<result<<endl;
            system("pause");
            break;
        case (4):
            result=1/(tan(x));                              //case4 cotanget
            cout<<"Your result: "<<result<<endl;
            outFile<<"Your result: "<<result<<endl;
            system("pause");
            break;
        case (5):
            result=1/(sin(x));                              //case5 cosecant
            cout<<"Your result: "<<result<<endl;
            outFile<<"Your result: "<<result<<endl;
            system("pause");
            break;
        case (6):
            result=1/(cos(x));                              //case6 secant
            cout<<"Your result: "<<result<<endl;
            outFile<<"Your result: "<<result<<endl;
            system("pause");
            break;

        case (7):
            z=1;
            break;

        default:
            system("cls");
            cout<<"Invalid\nPlease try again.";
            outFile<<"Invalid\nPlease try again.";
            Sleep(2000);                                //show choices expression 1-7

        }
        cout<<endl;
        outFile<<endl;
        system("cls");


    }
    outFile.close();


}


/*--------------------------------------------question 4------------------------------------------------*/

/*--------------------------------------------question 5------------------------------------------------*/

void showQuestion5()  //expression of Electrical Charge, Capacitance, Current, Voltages and Power
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    int select,pilih,c,v,i,t,z=0;
    float pi,vi,ri,ci,iv,rv,pv,ip,rp,vp;

    cout<<"\n\n1. Electrical Charge"<<"\n\n2. Capacitance"<<"\n\n3. Current"<<"\n\n4. Voltage"<<"\n\n5. Power"<<endl;
    cout<<"\nChoose your option: ";
    cin>>select;
    outFile<<"\n\n1. Electrical Charge"<<"\n\n2. Capacitance"<<"\n\n3. Current"<<"\n\n4. Voltage"<<"\n\n5. Power"<<endl;
    outFile<<"\nChoose your option: ";
    outFile<<select<<endl;
    system("cls");
    while(z<1)
    {

    switch (select)
    {
    case (1):
                                //user choose number 1=case1
        cout<<"1. Q=CV"<<"\n2. Q=It"<<endl;     //it display 1. Q=CV 2.Q=It
        cout<<"Option: ";                       //user makes the option of PILIH
        cin>>pilih;

        switch(pilih)
        {                                       //in PILIH have choices of using Q=CV or Q=It
        case (1):
             cout<<"\nCapacitance,C(F): ";
             cin>>c;                            //user put value of capacitance,v
             cout<<"\nVoltage,V(V): ";
             cin>>v;                             //user put value of voltage
             getCharge1(c,v);
             system("pause") ;                //calling the function of declaration getCharge1(int int)
             break;
        case (2):
             cout<<"\nCurrent,I(A): ";
             cin>>i;                            // user put value of Current,i
             cout<<"\nTime taken,t(s):";
             cin>>t;                            // user put value of Current,t
             getCharge2(i,t);
             system("pause");                   //calling the function of declaration getCharge2(int int)
             break;
        default:
        cout<<"Back to main menu.";
        }
        break;

    case (2):                                       //case2 for Capacitance
        cout<<"1. Series"<<"\n2. Parallel"<<endl;   //choose series or parallel
        cout<<"Option: ";
        cin>>pilih;                                 //user makes the option

        switch(pilih)                               //switch the option case1 or case2
        {
        case (1):
             getCapacitance1(ci);
             system("pause");                 //calling function of capacitance1(series)
             break;
        case (2):
             getCapacitance2(ci);
             system("pause");                   //calling function of capacitance2(parallel)
             break;
        default:
        cout<<"Back to main menu.";
        }
        break;


    case (3):                                       //case3 for current
        cout<<"1. I=V/R"<<"\n2. I=P/V"<<endl;       //makes the choice of formula current
        cout<<"Option: ";
        cin>>pilih;

        switch(pilih)
        {
        case (1):                               //choose the I=V/R
             cout<<"\nVoltage,V(V): ";            //put value of voltage,v
             cin>>vi;
             cout<<"\nResistance,R(ohm): ";       //put value of current,I
             cin>>ri;
             getCurrent1(vi,ri);
             system("pause");              //calling function of current1 I=V/R
             break;
        case (2):                               //Choose the I=P/V
             cout<<"\nPower,P(W): ";              //put value of power,P
             cin>>pi;
             cout<<"\nVoltage,V(V): ";            //Put value of Voltage,V
             cin>>vi;
             getCurrent2(pi,vi);
             system("pause");               //Calling Function of Current2
             break;
        default:
        cout<<"Back to main menu.";
        }
    break;

    case (4):                                   //case4 to choose Voltage,V
        cout<<"1. V=IR"<<"\n2. V=P/I"<<endl;    //option the voltage formula V=IR and V=P/I
        cout<<"Option: ";
        cin>>pilih;

        switch(pilih)
        {
        case (1):
             cout<<"\nCurrent,I(A): ";            //put value of current,I
             cin>>iv;
             cout<<"\nResistance,R(ohm): ";       //put value of resistance,R
             cin>>rv;
             getVoltage1(iv,rv);
             system("pause");               //calling function voltage1
             break;
        case (2):
             cout<<"\nPower,P(W): ";              //put value of power,P
             cin>>pv;
             cout<<"\nCurrent,I(A): ";            //put value of current,I
             cin>>iv;
             getVoltage2(pv,iv);
             system("pause");              //calling function voltage2
             break;
        default:
        cout<<"Back to main menu.";
        }
        break;

    case (5):                                                        //case5 for power
        cout<<"1. P=(I^2)R"<<"\n2. P=(V^2)/R"<<"\n3. P=IV"<<endl;   //option P=(I^2)R, P=(V^2)/R, P=IV
        cout<<"Option: ";
        cin>>pilih;

        switch(pilih)
        {
        case (1):                               //case1 : P=(I^2)R
             cout<<"\nCurrent,I(A): ";            //put value current,I
             cin>>ip;
             cout<<"\nResistance,R(ohm): ";       //put value Resistance,R
             cin>>rp;
             getPower1(ip,rp);
             system("pause");                  //calling function Power1
             break;
        case (2):                               //case2 : P=(V^20)/R
             cout<<"\nVoltage,V(V): ";            //put value Voltage,v
             cin>>vp;
             cout<<"\nResistance,R(ohm): ";       //put value Resistance,R
             cin>>rp;
             getPower2(vp,rp);
             system("pause");                //calling function Power2
             break;
        case (3):                               //case3 : P=IV
             cout<<"\nCurrent,I(A): ";            //put value Current,I
             cin>>ip;
             cout<<"\nVoltage,V(V): ";            //put value Voltage,v
             cin>>vp;
             getPower3(ip,vp);
             system("pause");                //calling function Power3
             break;
        default:
        cout<<"Back to main menu.";
        }

    break;
    default:
        cout<<"Invalid. Choose option 1-5."     //if take the another number from it would display Invalid.Choose1-5.Thank you.
            <<"Thank you.";

        showQuestion5();                        //choosing 1-5 of option Question5
    }

     z=1;                          //if correct it will go to the main
    }
    system("cls");
}


//function definition
//1.electrical charge
//charge Q=cv
void getCharge1(int c,int v)
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Electrical charge,Q="<<c*v<<"C"<<endl<<endl;
    outFile<<"Electrical charge,Q="<<c*v<<"C"<<endl;

     outFile.close();
}
//charge Q=it
void getCharge2(int i,int t)
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Electrical charge,Q="<<i*t<<"C"<<endl<<endl;
    outFile<<"Electrical charge,Q="<<i*t<<"C"<<endl;

     outFile.close();

}


//2.current
//Current1 i=v/r
void getCurrent1(float vi,float ri)
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Current: "<<vi/ri<<"A"<<endl;
    outFile<<"Current: "<<vi/ri<<"A"<<endl;

     outFile.close();
}
//Current2 i=p/v
void getCurrent2(float pi,float vi)
{
  ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Current: "<<pi/vi<<"A"<<endl;
    outFile<<"Current: "<<pi/vi<<"A"<<endl;

     outFile.close();
}


//3.capacitance
//Capacitence1 in series
void getCapacitance1 (float ci)
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    float num=0;
    ci=1;
    do
    {
        num+=1/ci;
        cout<<"Enter the value of capacitance(0 to exit): ";
        cin>>ci;

    }while(ci!=0);

    cout<<"The series of capacitance: "<<1/(num-1)<<"uF"<<endl;
    outFile<<"The series of capacitance: "<<1/(num-1)<<"uF"<<endl;

     outFile.close();
}
//Capacitence2 in Parallel
void getCapacitance2 (float ci)
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    float num=0;
    do
    {
        cout<<"Enter the value of capacitance(0 to exit): ";
        cin>>ci;
        num+=ci;
    }while(ci!=0);

    cout<<"The parallel of capacitance: "<<num<<"uF"<<endl;
    outFile<<"The parallel of capacitance: "<<num<<"uF"<<endl;

     outFile.close();
}


//4.voltage
//Voltage1 V=ir
void getVoltage1 (float iv, float rv )
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"voltage: "<<iv*rv<<"V"<<endl;
    outFile<<"voltage: "<<iv*rv<<"V"<<endl;

     outFile.close();
}
//Voltage2 V=p/i
void getVoltage2 (float pv, float iv)
{
  ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Voltage: "<<pv/iv<<"V"<<endl;
    outFile<<"Voltage: "<<pv/iv<<"V"<<endl;

     outFile.close();
}


//5.power
//Power1 P=i^2*r
void getPower1 (float ip, float rp)
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Power: "<<pow(ip,2)*rp<<"W"<<endl;
    outFile<<"Power: "<<pow(ip,2)*rp<<"W"<<endl;

     outFile.close();
}
//Power2 P=(V^2)/r
void getPower2 (float vp, float rp)
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Power: "<<pow(vp,2)/rp<<"W"<<endl;
    outFile<<"Power: "<<pow(vp,2)/rp<<"W"<<endl;

     outFile.close();
}
//Power3 P=iV
void getPower3 (float ip, float vp)
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    cout<<"Power: "<<ip*vp<<"W"<<endl;
    outFile<<"Power: "<<ip*vp<<"W"<<endl;

     outFile.close();
}

/*--------------------------------------------question 5------------------------------------------------*/
/*--------------------------------------------question 6------------------------------------------------*/
//expression of perimeter,Area and Volume
void showQuestion6()

{
    int choice,r,l,w,h,choose,z=0;

    cout<<"\n1. Circumference"<<"\n\n2. Area of rectangles"
        <<"\n\n3. Area of circles"<<"\n\n4. Volume of rectangles/prism"
        <<"\n\n5. Volume of circle/sphere"<<endl;
    cout<<"\n\nChoose your option: ";
    cin>>choice;

    while(z<1)
    {

    switch (choice)
    {
    case (1):
        cout<<"Radius: ";
        cin>>r;
        getCircumference(r);
        break;
    case (2):
        cout<<"Lenght and Width: ";
        cin>>l>>w;
        getAreaRec(l,w);
        break;
    case (3):
        cout<<"Radius: ";
        cin>>r;
        getAreaCircle(r);
        break;
    case (4):
        cout<<"Lenght, Width and height: ";
        cin>>l>>w>>h;
        getVolumeRec(l,w,h);
        break;
    case (5):
        cout<<"Radius: ";
        cin>>r;
        getVolumeCircle(r);
        break;
    default:
        cout<<"Invalid. Choose option 1-5."
            <<"Thank you.";


    }
    z=1;
    }
}


//function definition
//1.Circumference
void getCircumference(float r)
{
 ofstream outFile;
    outFile.open("all.txt",fstream::app);
    question6 value;
    value.result=2*PI*r;
    cout<<"Circumference is: "<<value.result<<endl;
    outFile<<"Circumference is: "<<value.result<<endl;
    outFile.close();
}
//2. Area of Rectangle
void getAreaRec(float l,float w)
{
     ofstream outFile;
    outFile.open("all.txt",fstream::app);
    question6 value;
    value.result=l*w;
    cout<<"Area of rectangle is: "<<value.result<<endl;
    outFile<<"Area of rectangle is: "<<value.result<<endl;
    outFile.close();
}
//3. Area of Circle
void getAreaCircle(float r)
{
  ofstream outFile;
    outFile.open("all.txt",fstream::app);
    question6 value;
    value.result=PI*pow(r,2);
    cout<<"Area of circle is: "<<value.result<<endl;
    outFile<<"Area of circle is: "<<value.result<<endl;
    outFile.close();
}
//4.Volume of prism
void getVolumeRec(float l,float w,float h)
{
      ofstream outFile;
    outFile.open("all.txt",fstream::app);
    question6 value;
    value.result=l*w*h;
    cout<<"Volume of prism is: "<<value.result<<endl;
    outFile<<"Volume of prism is: "<<value.result<<endl;
    outFile.close();

}
//5.Volume of Sphere
void getVolumeCircle(float r)
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    question6 value;
    value.result=(4*PI*pow(r,3))/3;
    cout<<"Volume of sphere is: "<<value.result<<endl;
    outFile<<"Volume of sphere is: "<<value.result<<endl;
    outFile.close();
}

/*--------------------------------------------question 6------------------------------------------------*/
/*--------------------------------------------question 7------------------------------------------------*/
//Expression of Quadratic Equation
void showQuestion7()
{
    ofstream outFile;
    outFile.open("all.txt",fstream::app);
    int a,b,c;
    cout<<"Please enter the value of a , b and c:";
    cout<<"\na: ";
    cin>>a;
    cout<<"\nb: ";
    cin>>b;
    cout<<"\nc: ";
    cin>>c;
    outFile<<"\nPlease enter the value of a , b and c:";
    outFile<<"\na: ";
    outFile<<a<<endl;
    outFile<<"\nb: ";
    outFile<<b<<endl;
    outFile<<"\nc: ";
    outFile<<c<<endl;

    cout<<"Your quadratic function is:"<<a<<"x^2+"<<b<<"x+"<<c<<endl;
    outFile<<"Your quadratic function is:"<<a<<"x^2+"<<b<<"x+"<<c<<endl;
    getValue(a,b,c);
    cout<<endl;
    outFile<<endl;
    system("pause");
    system("cls");

}

//Function Declaration
//Quaratic function root and no real root number
void getValue(float a,float b,float c)
{
   ofstream outFile;
    outFile.open("all.txt",fstream::app);
    float x,x1,x2,y;
    y=pow(b,2)-(4*a*c);
    if(y<0)
    {
        cout<<"There is no real root";
        outFile<<"There is no real root";
    }

    if(y>0)
    {
        cout<<"There is two real root.\n";
        outFile<<"There is two real root.\n";
        x1=((-1*b)+sqrt(y))/(2*a);
        x2=((-1*b)-sqrt(y))/(2*a);
        cout<<"x1: "<<x1<<" and x2: "<<x2;
        outFile<<"x1: "<<x1<<" and x2: "<<x2;
    }


    if(y==0)
    {
        cout<<"There is one real root.\n";
        outFile<<"There is one real root.\n";
        x1=((-1*b)+sqrt(y))/(2*a);
        cout<<"x: "<<x1;
        outFile<<"x: "<<x1;
    }
    outFile.close();
}


/*--------------------------------------------question 7------------------------------------------------*/


# data[].attributes.body
Gilbertson Mitchell anak Ko
Justin anak Tigong

# data[].attributes.body
Gilbertson Mitchell anak Ko
Justin anak Tigong

# data[].attributes.body
Gilbertson Mitchell anak Ko
Justin anak Tigong

# data[].attributes.body
Khairul Akmal Bin Arshad
Hamizah binti Hamdan

# data[].attributes.body
Khairul Akmal Bin Arshad
Hamizah Binti Hamdan

# data[].attributes.body
Khairul Akmal Bin Arshad
Hamizah binti Hamdan

# data[].attributes.body
Mohammad Izzuan bin Ishak
Muhammed Azril bin Mustapha

# data[].attributes.body
Muhd Afiq Nasruddin
Abg. Mohd. Anis Sufi
Baninnukman

# data[].attributes.body
Muhd Afiq Nasruddin
Abg. Mohd. Anis Sufi
Baninnukman

# data[].attributes.body
Muhd Afiq Nasruddin
Abg. Mohd. Anis Sufi
Baninnukman

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <stdlib.h>
#include <conio.h>
using namespace std;

const int pI = 3.142;

void MainMenu();
void ScalarValue();
void Matrices();
void BaseCon();
void TrigoOp();
void EleC();
void SoGeo();
void QuadE();
void OpenFile();
void Quit();

void bina(int);
void findRoot(double,double,double);
void findmul();

struct shape
{
    double l;
    double w;
    double h;
};

struct shape2
{
    double r;
    double circum;
};

int main()
{
    double y = 1.0;
    char choice;

    MainMenu();

    while(y)
{
        choice = getche();

        switch(choice)
        {
            case 'S':
                    ScalarValue();
                    break;

            case 'M':
                    Matrices();
                    break;

            case 'B':
                    BaseCon();
                    break;

            case 'T':
                    TrigoOp();
                    break;

            case 'E':
                    EleC();
                    break;

            case 'G':
                    SoGeo();
                    break;

            case 'Q':
                    QuadE();
                    break;

            case 'O':
                    OpenFile();
                    break;

            case 'Y':
                    MainMenu();
                    break;

            case 'Z':
                    system("cls");
                    MainMenu();
                    break;

            case 'X':
                    Quit();
                    return 0;
                    break;

            default:
            cout<<endl;
            cout<<endl;
            cout<<"You have entered unavailable option."<<endl;
            cout<<"Please Enter any one of below available options."<<endl;
            MainMenu();

        }

    }


}

void MainMenu()
{
    cout<<endl;
    cout << "\t\t\t\t\t Welcome to our Scientific Calculator\t\t" << endl;
    cout << "\t\t\t\t\t------------------------------------" << endl;
    cout << "\t\t\t\t\t'S' for Scalar Value\t\t" << endl;
    cout << "\t\t\t\t\t'M' for Matrices\t\t" << endl;
    cout << "\t\t\t\t\t'B' for Base Conversion\t\t" << endl;
    cout << "\t\t\t\t\t'T' for Trigonometric Operation\t\t" << endl;
    cout << "\t\t\t\t\t'E' for Electrical Charges\t\t" << endl;
    cout << "\t\t\t\t\t'G' for Solid Geometrical Calculation\t\t" << endl;
    cout << "\t\t\t\t\t'Q' for Quadratic Equations\t\t" << endl;
    cout << "\t\t\t\t\t'O' to Open Saved Files\t\t" << endl;
    cout << "\t\t\t\t\t'Y' to Return to Main Menu\t\t" << endl;
    cout << "\t\t\t\t\t'Z' to Reset the Calculator\t\t" << endl;
    cout << "\t\t\t\t\t'X' to Exit the Calculator\t\t" << endl;
    cout << "\t\t\t\t\tPlease choose the options available above : \t\t" << endl;
    cout << endl;
}

void ScalarValue()
{
    char answer;
    float num1, num2;
    float a,b,c,d;
    float *p, *q;

    cout << endl;
    cout << "------------------------------------------" << endl;
    cout << "A - Addition" << endl;
    cout << "S - Subtraction" << endl;
    cout << "M - Multiplication" << endl;
    cout << "D - Division" << endl;
    cout << "Please choose the operand either 'A' or 'S' or 'M' or 'D' : ";
    cin >> answer;
    cout << "Your choice is : "<< answer << endl;

    p = &num1;
    q = &num2;

    cout << "Enter two operands : ";
    cin >> *p >> *q ;
    cout << "The first integer is : "<< *p << endl;
    cout << "The second integer is : "<< *q << endl;

    ofstream File;
    File.open ("Addition.txt");

    ofstream File2;
    File2.open ("Subtraction.txt");

    ofstream File3;
    File3.open ("Multiplication.txt");

    ofstream File4;
    File4.open ("Division.txt");


    switch(answer)
    {
        case 'A':
            a = *p + *q;
            cout <<"The answer is : "<< a;
            break;

        case 'S':
            b = *p - *q;
            cout <<"The answer is : "<< b;
            break;

        case 'M':
            c = *p * *q;
            cout <<"The answer is : "<< c;
            break;

        case 'D':
            d = *p / *q;
            cout <<"The answer is : "<< d;
            break;

        default:
            // If the chosen operand is neither the choices given, syntax error occurs
            cout << "Syntax Error! Please try again!";
            break;
    }
        File << *p << endl;
        File << *q << endl;
        File << a << endl;

        File2 << *p << endl;
        File2 << *q << endl;
        File2 << b << endl;

        File3 << *p << endl;
        File3 << *q << endl;
        File3 << c << endl;

        File4 << *p << endl;
        File4 << *q << endl;
        File4 << d << endl;
}

void Matrices()
{
    cout << endl;
    cout << "Enter 1 - Addition, Division and Subtraction" << endl;
    cout << "Enter 2 - Multiplication" << endl;
    char Choice;
    cout << "Enter your choice : ";
    cin >> Choice;

    switch(Choice)
    {

     case '1':
        int q, w, e, x, array1[10][10], array2[10][10] ;
        int add[10][10], minu[10][10], mul[10][10],divs[10][10];
        cout << endl;
        cout << "Enter the rows and columns of matrices : ";
        cin >> q >> w;
        cout << "Key in the integers of array1 : " << endl;

        for (  e = 0 ; e < q ; e++ )
        for ( x = 0 ; x < w ; x++ )
        cin >> array1[e][x];

        cout << "Key in the integers of array2 : " << endl;

        for ( e = 0 ; e < q ;e++ )
        for ( x = 0 ; x < w ; x++ )
        cin >> array2[e][x];

        for ( e = 0 ; e < q ; e++ )
        for ( x = 0 ; x < w ; x++ )
        add[e][x] = array1[e][x] + array2[e][x];


        cout << "Total of matrices : " << endl;

        for ( e = 0 ; e < q ; e++ )
{
        for ( x = 0 ; x < w ; x++ )
        cout << add[e][x] << "\t";

        cout << endl;

};
        for ( e = 0 ; e < q ; e++ )
        for ( x = 0 ; x < w ; x++ )
        minu[e][x] = array1[e][x] - array2[e][x];

        cout << "Subtraction of matrices : " << endl;

        for ( e = 0 ; e < q ; e++ )
{
        for ( x = 0 ; x < w ; x++ )
        cout << minu[e][x] << "\t";

        cout << endl;
};
        for ( e = 0 ; e < q ; e++ )
        for ( x = 0 ; x < w ; x++ )
        divs[e][x] = array1[e][x] / array2[e][x];

        cout << "Division of matrices : " << endl;
        for ( e = 0 ; e < q ; e++ )
{
        for ( x = 0 ; x < w ; x++ )
        cout << divs[e][x] << "\t";


}
        break;

     case '2':
        findmul();
        break;
}
}

void BaseCon()
{
    double integer;
	char answer;

	cout << endl;
	cout << "B for binary, H for Hexadecimal. Please choose : ";
	cin >> answer;

	switch(answer)
	{
	    case 'B':
        cout << "Please enter a number : ";
        cin >> integer;
        cout << "You chose the number : " << integer << endl;

        if (integer < 0)
        cout << "Error! Please enter a positive integer! " << endl;

        else
        {

		cout << "The number in binary is : " << endl;
		bina(integer);
		cout << endl;
        }
        break;

        case 'H':
        int num,quot;
        int a = 1, b ,ans;
        char hex[100];

        cout << "Enter any decimal number: ";
        cin >> num;

        quot = num;

        while(quot!=0)
{
        ans = quot % 16;


        if( ans < 10)
        ans = ans + 48;
        else
        ans = ans + 55;

        hex[a++]= ans;
        quot = quot / 16;
}
        cout << "The hexadecimal number is : ";
        for (b = a - 1 ; b > 0 ; b--)
        cout << hex[b];
        cout << endl;
        break;
}

}

void TrigoOp()
{
    ofstream Angle;
    Angle.open ("Values of Angle.txt");
    double dsine, dcos, dtan;
    double cosec, sec, cot;
    double theta;
    double radi;

    cout << fixed << showpoint << setprecision(2);

    cout << endl;
    cout << "Enter the value of angle : ";
    cin >> theta;

    radi = theta * (pI/180);
    dcos = cos(radi);
    dsine = sin(radi);
    dtan = tan(radi);

    cout << "Cos value is : " << dcos << endl;
    cout << "Sin value is : " << dsine << endl;
    cout << "Tan value is : " << dtan << endl;

    sec = (1/dcos);
    cosec = (1/dsine);
    cot = (1/dtan);

    cout << "Secant value is : " << sec << endl;
    cout << "Cosecant value is : " << cosec << endl;
    cout << "Cotangent value is : " << cot << endl;

    Angle << dcos << endl;
    Angle << dsine << endl;
    Angle << dtan << endl;
    Angle << sec << endl;
    Angle << cosec << endl;
    Angle << cot << endl;
}

void EleC()
{
    char answer;
    double EleCharges, CapaC, Cur, Resist, Volt, Pow;
    double a,b,c,x,d,y,z,e,q,w;
    double sum = 0,sum2 = 0;

    cout << fixed << showpoint << setprecision(2);

    cout << "Enter choice either 'C' for Capacitance or 'I' for Current" << endl << " or 'E' for Electrical Charges : "<<endl;
    cin >> answer;
    cout << "Your choice is : "<< answer << endl;

    ofstream    capaC;
    capaC.open ("CapacitorsValue.txt");
    ofstream capaC2;
    capaC2.open ("Parameters.txt");
    ofstream capaC3;
    capaC3.open ("ElectricalCharges.txt");

    switch (answer)
    {
        case 'C':

        while(1)
        {

        cout << "Please enter the parameter (Capacitor Value / -1 to quit) : ";
        cin >> CapaC;

        if (CapaC == -1)
        {
        break;
        }
        e += (1/CapaC);
        sum = (1/(1/e));
        w = sum;
        cout << "The total series capacitance is : " << (1/sum) << endl;

        sum2 = sum2 + CapaC;
        q = sum2;
        cout << "The total parallel capacitance is : " << sum2 << endl;


        }
        break;

        case 'I':
        cout << "Current value : ";
        cin >> Cur;

        cout << "Resistance value : ";
        cin >> Resist;

        Volt = Cur * Resist;
        cout << "Voltage value : " << Volt << endl;
        cout << "Current value (given by user) : " << Cur << endl;

        Pow = Cur * Volt;
        cout << "The value of Power is : " << Pow;
        break;

        case 'E':
        cout << "First 100 units : ";
        cin >> x;
        cout << "Next 200 units : ";
        cin >> y;
        cout << "Above 300 units : ";
        cin >> z;


        a = x * 0.18; // based on Sarawak Energy billing rating
        b = y * 0.22;
        c = z * 0.25;

        EleCharges = a + b + c;
        cout << "The total Electric Charges for this month is : RM" << EleCharges;
        break;

    }
        capaC << w << endl;
        capaC << q << endl;
        capaC2 << Cur << endl;
        capaC2 << Resist << endl;
        capaC2 << Volt << endl;
        capaC2 << Pow << endl;
        capaC3 << x << endl;
        capaC3 << y << endl;
        capaC3 << z << endl;
        capaC3 << EleCharges << endl;
    }

void SoGeo()
{
   double area, volume;
    shape Rectangle;
    shape2 Circle;
    char answer;

    cout << endl;
    cout << "Enter choice either 'R' for Rectangle or 'C' for Circle : ";
    cin >> answer;

    ofstream Shape0;
    Shape0.open ("Rectangle.txt");

    ofstream Shape1;
    Shape1.open ("Circle.txt");

switch(answer)
{
    case 'R':

    cout << "Length (cm) : ";
    cin >> Rectangle.l;
    cout << "Width (cm) : ";
    cin >> Rectangle.w;
    cout << "Height (cm) : ";
    cin >> Rectangle.h;

    area = Rectangle.l * Rectangle.h;
    volume = Rectangle.l * Rectangle.h * Rectangle.w;

    cout << "Area of the Rectangle is : " << area << "cm2 \n";
    cout << "Volume of the Rectangle is : " << volume << "cm3 \n";

    Shape0 << Rectangle.l << endl;
    Shape0 << Rectangle.w << endl;
    Shape0 << Rectangle.h << endl;
    Shape0 << area << endl;
    Shape0 << volume << endl;

    break;

    case 'C':
    cout << "Radius : ";
    cin >> Circle.r;

    Circle.circum = 2 * pI * Circle.r;
    area = pI * pow(Circle.r,2);
    volume = (4/3) * pI * pow(Circle.r,3);

    cout << "Circumference of the circle is : " << Circle.circum << "cm\n";
    cout << "Area of circle is : " << area << "cm2\n";
    cout << "Volume of the circle is : " << volume << "cm3\n";


    Shape1 << Circle.r << endl;
    Shape1 << Circle.circum << endl;
    Shape1 << area << endl;
    Shape1 << volume << endl;
    break;

    }

}

void QuadE()
{
    int f, g, h;
    double root;

    cout << endl;
    cout << "Key in 3 numbers : " << endl;
    cin >> f >> g >> h;

    cout << "Your quadratic function is " << f << "x^2 + " << g << "x + " << h <<  endl;
    cout << "Now this program will find it's roots...." << endl;

    findRoot (f,g,h);
}
void OpenFile()
{
    string x;
    char file;

    cout << endl;
    cout << "A - Addition File" << endl;
    cout << "S - Subtraction File" << endl;
    cout << "M - Multiplication File" << endl;
    cout << "D - Division" << endl;
    cout << "T - Values of Angles File" << endl;
    cout << "C - Capacitors Value File" << endl;
    cout << "P - Parameters File" << endl;
    cout << "E - Electrical Charges" << endl;
    cout << "R - Rectangle" << endl;
    cout << "B - Circle" << endl;
    cout << "Q - Root(No Root)" << endl;
    cout << "W - Root(Real)" << endl;
    cout << "Y - Root(One)" << endl;

    cout << "Please choose a file to open : " << endl;
    cin >> file;

switch (file)
    {

    case 'A':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Addition.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'S':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Subtraction.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'M':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Multiplication.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'D':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Division.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'T':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Values of Angle.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'C':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("CapacitorsValue.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'P':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Parameters.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'E':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("ElectricalCharges.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'R':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Rectangle.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'B':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Circle.txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'Q':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Root(No Root).txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'W':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Root(Real).txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }

    case 'Y':
    {
    ifstream    OpenFiles1;
    OpenFiles1.open ("Root(One).txt");
    while   (OpenFiles1 >> x)
    cout << x << endl;
    break;
    }
}
}
void Quit()
{
    cout << endl;
    cout << "Thank you for using this calculator! :D" << endl;
}
void bina (int integer)
{
   int remain;

	if(integer <= 1)
{
    cout << integer;
    return;
}

	remain = integer%2;
	bina(integer >> 1);
	cout << remain;
}
void findRoot(double f, double g, double h)
{
    ofstream Root;
    Root.open ("Root(No Root).txt");

    ofstream Root2;
    Root2.open ("Root(Real).txt");

    ofstream Root3;
    Root3.open ("Root(One).txt");

    float P;
    float Q;
    float root1, root2;
    P = g*g - 4*f*h;

    if (P < 0)
{
    cout << "The Value of P is : " << P << endl;
    cout << "No real roots.";
    Root << P;
}
    if (P > 0)
    {
       cout << "Two real roots.";
       root1 = ((g*-1) + sqrt (P))/(2*f);
       root1 = ((g*-1) - sqrt (P))/(2*f);
       cout << "The roots are : " << root1 << root2 << endl;
       Root2 << root1 << endl;
       Root2 << root2 << endl;
    }


    if (P == 0)
    {
        cout << "One root.";
        root1 = ((g*-1) + P)/(2*f);
        cout << "The root is : " << root1 << endl;
        Root3 << root1 << endl;
}
}

void findmul()
{
    int matr1[10][10], matr2[10][10], matr3[10][10];
    int q, w, o, e, m, n;

    cout << "Enter the number of rows and columns for Matrix 1 : "<< endl;
    cin >> q >> w;


    cout << "Enter elements for Matrix 1 : " << endl;
    for (o = 0; o < q; o++)
    {
        for (e = 0; e < w; e++)
        {
            cin >> matr1[o][e];
        }

        cout << endl;
    }
    cout << "Matrix 1 : " << endl;
    for (o = 0; o < q; o++)
    {
        for (e = 0; e < w; e++)
        {
            cout << "\t" << matr1[o][e];
        }
        cout << endl;
    }
    cout << "\n-----------------------------------------------------------\n";
    cout << "Enter the number of rows and columns for Matrix 2 : " << endl;
    cin >> m >> n;


    cout << "Enter elements for Matrix 2 : " << endl;
    for (o = 0; o < m; o++)
    {
        for (e = 0; e < n; e++)
        {
            cin >> matr2[o][e];
        }
        cout << endl;
    }
    cout << "Matrix 2 : " << endl;
    for (o = 0; o < m; o++)
    {
        for (e = 0; e < n; e++)
        {
            cout << "\t" << matr2[o][e];
        }
        cout << endl;
    };
    for (o = 0; o < q; o++)
        {
            for (e = 0; e < n ; e++)
            {
                matr3[o][e = 0];
                for (int k = 0; k < m; k++)
                {
                    matr3[o][e] = matr3[o][e] + matr1[o][k] * matr2[k][e];
                }
            }
        }

        cout << "\n-----------------------------------------------------------\n";
        cout << "Multiplication of Matrix 1 and Matrix 2 : " << endl;

        for (o = 0; o < q; o++)
        {
            for (e = 0; e < n; e++)
            {
                cout << "\t" << matr3[o][e];
            }
            cout << endl;
        }
}

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<windows.h>
#include<cmath>
#include<iomanip>
#include<string>
#include<fstream>
#define MAX 1000
double pi=3.14159;
using namespace std;
void mainMenu(); void menu(); void openFile();
void arithmetic(); void addition(); void subtraction(); void multiplication(); void division();
void matrices(); void addMatr(); void subMatr(); void mulMatr();
void digitalConversion(); void binary(int); int decimalConverter(); unsigned long convTodecnum(char hex[]);
void trigoCalc();
void elecCalc(); void charge(); void capcitance(); void currrent(); void voltage (); void power();
void solidCalc();
struct side
{
    double length;
    double height;
    double width;
    double radius;

};
void quadraticEquat(); double calcX(double,double,int,int,int);

int main()
{
    int choice;
    cout << endl << endl << endl;
    cout << "\t\t\t\t -------------------------------" << endl;
    cout << "\t\t\t\t| Engineering Calculator.       |" << endl;
    cout << "\t\t\t\t| 1. Arithmetic calculation     |" << endl;
    cout << "\t\t\t\t| 2. Matrices calculation       |" << endl;
    cout << "\t\t\t\t| 3. Digital number conversion  |" << endl;
    cout << "\t\t\t\t| 4. Trigonometric calculation  |" << endl;
    cout << "\t\t\t\t| 5. Electrical calculation     |" << endl;
    cout << "\t\t\t\t| 6. Solid calculation          |" << endl;
    cout << "\t\t\t\t| 7. Quadratic equation solving |" << endl;
    cout << "\t\t\t\t| 8. Open history               |" << endl;
    cout << "\t\t\t\t -------------------------------" << endl << endl;
    cout << "\t\t\t\t Enter your choice: ";
    cin >> choice;

    if ( choice == 1)
    {
        arithmetic();
    }

    if ( choice == 2)
    {
        matrices();
    }

    if ( choice == 3)
    {
        digitalConversion();
    }

    if ( choice == 4)
    {
        trigoCalc();
    }

    if ( choice == 5)
    {
        elecCalc();
    }

    if ( choice == 6)
    {
        solidCalc();
    }

    if ( choice == 7)
    {
        quadraticEquat();
    }
    if ( choice == 8)
    {
        openFile();
    }

    return 0;
}
//Main Menu
void mainMenu()
{
    int choice;
    cout << endl << endl << endl;
    cout << "\t\t\t\t -------------------------------" << endl;
    cout << "\t\t\t\t| Engineering Calculator.       |" << endl;
    cout << "\t\t\t\t| 1. Arithmetic calculation     |" << endl;
    cout << "\t\t\t\t| 2. Matrices calculation       |" << endl;
    cout << "\t\t\t\t| 3. Digital number conversion  |" << endl;
    cout << "\t\t\t\t| 4. Trigonometric calculation  |" << endl;
    cout << "\t\t\t\t| 5. Electrical calculation     |" << endl;
    cout << "\t\t\t\t| 6. Solid calculation          |" << endl;
    cout << "\t\t\t\t| 7. Quadratic equation solving |" << endl;
    cout << "\t\t\t\t| 8. Open history               |" << endl;
    cout << "\t\t\t\t -------------------------------" << endl << endl;
    cout << "\t\t\t\t Enter your choice: ";
    cin >> choice;

    if ( choice == 1)
    {
        arithmetic();
    }

    if ( choice == 2)
    {
        matrices();
    }

    if ( choice == 3)
    {
        digitalConversion();
    }

    if ( choice == 4)
    {
        trigoCalc();
    }

    if ( choice == 5)
    {
        elecCalc();
    }

    if ( choice == 6)
    {
        solidCalc();
    }

    if ( choice == 7)
    {
        quadraticEquat();
    }
    if ( choice == 8)
    {
        openFile();
    }
}
//Menu
void menu()
{
    int opt;
    cout << endl << endl;
    cout << "----------------------------------" << endl;
    cout << "Enter 1 to back to main menu." << endl;
    cout << "Enter 2 exit." << endl;
    cout << "Enter your choice: ";
    cin >> opt;

    if ( opt == 1)
    {
        system("cls");
        mainMenu();
    }
    if (opt == 2)
    {
        system("cls");
        cout << endl << endl;
        cout << "----------------------------------" << endl;
        cout << "Thank You For Using This Program" << endl;
        cout << "----------------------------------" << endl;
    }
}
void openFile()
{
    system("cls");
    ifstream inputFile;
    string filename;
    string number;

    cout << "Enter the filename: ";
    cin >> filename;

   //inputFile.open(filename);
    inputFile.open(filename.c_str());

   // If the file successfully opened, process it.
    if (inputFile)
    {
      // Read the numbers from the file and
      // display them.
      while (inputFile >> number)
      {
         cout << number << " ";
      }

      // Close the file.
    inputFile.close();
    cout << endl << endl;
    menu();
    }
    else
    {
	   cout << "Error opening the file.\n";
	   menu();
    }
}
//Arithmetic Calculation
void arithmetic()
{
    system("cls");
    int option;
    cout << "Arithmetic Calculation:" << endl;
    cout << "1. Addition" << endl;
    cout << "2. Subtraction" << endl;
    cout << "3. Multiplication" << endl;
    cout << "4. Division" << endl << endl;
    cout << "Enter your option: ";
    cin >> option;
    cout << endl;
    if (option == 1)
    {
        addition();
    }

    if (option == 2)
    {
        subtraction();
    }

    if (option == 3)
    {
        multiplication();
    }

    if (option == 4)
    {
        division();
    }
}
//Arithmetic Function(pointer)
void addition()
{
    system("cls");
    int x , y, ans, ch;
    int *xPtr = &x;
    int *yPtr = &y;
    cout << "\tAddition" << endl << endl;
    cout << "Enter 2 value:" << endl;
    cin >> *xPtr >> *yPtr;
    ans = *xPtr + *yPtr;
    cout << "The answer "<< *xPtr <<" + " << *yPtr << " = " << ans << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The answer "<< *xPtr <<" + " << *yPtr << " = " << ans << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
    if (ch == 2)
    {
        menu();
    }
}
void subtraction()
{
    system("cls");
    int x , y, ans, ch;
    int *xPtr = &x;
    int *yPtr = &y;
    cout << "\tSubtraction" << endl << endl;
    cout << "Enter 2 value:" << endl;
    cin >> *xPtr >> *yPtr;
    ans = *xPtr - *yPtr;
    cout << "The answer "<< *xPtr <<" - " << *yPtr << " = " << ans << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The answer "<< *xPtr <<" - " << *yPtr << " = " << ans << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
      if ( ch ==2 )
        {
            menu();
        }
}
void multiplication()
{
    system("cls");
    int x , y, ans, ch;
    int *xPtr = &x;
    int *yPtr = &y;
    cout << "\tMultiplication" << endl << endl;
    cout << "Enter 2 value:" << endl;
    cin >> *xPtr >> *yPtr;
    ans = *xPtr * *yPtr;
    cout << "The answer "<< *xPtr <<" x " << *yPtr << " = " << ans << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The answer "<< *xPtr <<" x " << *yPtr << " = " << ans << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
      if ( ch ==2 )
        {
            menu();
        }
}
void division()
{
    system("cls");
    double x , y, ans, ch;
    double *xPtr = &x;
    double *yPtr = &y;
    cout << "\tDivision" << endl << endl;
    cout << "Enter 2 value:" << endl;
    cin >> *xPtr >> *yPtr;
    ans = *xPtr / *yPtr;
    cout << "The answer "<< x <<" / " << y << " = " << ans << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The answer "<< *xPtr <<" / " << *yPtr << " = " << ans << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
}
//Matrices Calculation(array)
void matrices()
{
    system("cls");
    int option;
    cout << "Matrices Calculation" << endl;
    cout << "1. Addition" << endl;
    cout << "2. Subtraction" << endl;
    cout << "3. Multiplication" << endl << endl;
    cout << "Enter your option: ";
    cin >> option;

    if ( option == 1)
    {
        addMatr();
    }
    if ( option == 2)
    {
        subMatr();
    }
    if ( option == 3)
    {
        mulMatr();
    }
}
//Matrices Function
void addMatr()
{
    system("cls");
    cout << "Addition of matrices" << endl;
    int r, c, i, j, ch, a[100][100], b[100][100], sum[100][100];

    cout << "Enter number of rows: ";
    cin >> r;

    cout << "Enter number of columns: ";
    cin >> c;

    cout << endl << "Enter elements of 1st matrix: " << endl;

    // Storing elements of first matrix entered by user.
    for(i = 0; i < r; ++i)
       for(j = 0; j < c; ++j)
       {
           cout << "Enter element a" << i << j << " : ";
           cin >> a[i][j];
       }

    // Storing elements of second matrix entered by user.
    cout << endl << "Enter elements of 2nd matrix: " << endl;
    for(i = 0; i < r; ++i)
       for(j = 0; j < c; ++j)
       {
           cout << "Enter element b" << i << j << " : ";
           cin >> b[i][j];
       }

    // Adding Two matrices
    for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
            sum[i][j] = a[i][j] + b[i][j];

    // Displaying the resultant sum matrix.
    cout << endl << "Sum of two matrix is: " << endl;
    for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
        {
            cout << setw(5) << sum[i][j] << "  ";
            if(j == c - 1)
                cout << endl;
        }
    cout << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Sum of two matrix is: " << endl;
        for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
        {
            outFile << setw(5) << sum[i][j] << "  ";
            if(j == c - 1)
                outFile << endl;
        }
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
}
void subMatr()
{
    system("cls");
    cout << "Subtraction of matrices" << endl;
    int r, c, i, j, ch, a[100][100], b[100][100], sum[100][100];

    cout << "Enter number of rows: ";
    cin >> r;

    cout << "Enter number of columns: ";
    cin >> c;

    cout << endl << "Enter elements of 1st matrix: " << endl;

    // Storing elements of first matrix entered by user.
    for(i = 0; i < r; ++i)
       for(j = 0; j < c; ++j)
       {
           cout << "Enter element a" << i << j << " : ";
           cin >> a[i][j];
       }

    // Storing elements of second matrix entered by user.
    cout << endl << "Enter elements of 2nd matrix: " << endl;
    for(i = 0; i < r; ++i)
       for(j = 0; j < c; ++j)
       {
           cout << "Enter element b" << i << j << " : ";
           cin >> b[i][j];
       }

    // Subtract Two matrices
    for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
            sum[i][j] = a[i][j] - b[i][j];

    // Displaying the resultant sum matrix.
    cout << endl << "Subtraction of two matrix is: " << endl;
    for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
        {
            cout << setw(5) << sum[i][j] << "  ";
            if(j == c - 1)
                cout << endl;
        }
    cout << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Subtraction of two matrix is: " << endl;
        for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
        {
            outFile << setw(5) << sum[i][j] << "  ";
            if(j == c - 1)
                outFile << endl;
        }
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
}
void mulMatr()
{
    system("cls");
    cout << "Multiplication of matrices" << endl;
    int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k, ch;

    cout << "Enter rows and columns for 1st matrix: ";
    cin >> r1 >> c1;
    cout << "Enter rows and columns for 2nd matrix: ";
    cin >> r2 >> c2;

    // If column of first matrix in not equal to row of second matrix,
    // ask the user to enter the size of matrix again.
    while (c1!=r2)
    {
        cout << "Error! column of first matrix not equal to row of second.";

        cout << "Enter rows and columns for 1st matrix: ";
        cin >> r1 >> c1;

        cout << "Enter rows and columns for 2nd matrix: ";
        cin >> r2 >> c2;
    }

    // Storing elements of first matrix.
    cout << endl << "Enter elements of 1st matrix:" << endl;
    for(i = 0; i < r1; ++i)
        for(j = 0; j < c1; ++j)
        {
            cout << "Enter element a" << i << j << " : ";
            cin >> a[i][j];
        }

    // Storing elements of second matrix.
    cout << endl << "Enter elements of 2nd matrix:" << endl;
    for(i = 0; i < r2; ++i)
        for(j = 0; j < c2; ++j)
        {
            cout << "Enter element b" << i << j << " : ";
            cin >> b[i][j];
        }

    // Initialize elements of matrix
    for(i = 0; i < r1; ++i)
        for(j = 0; j < c2; ++j)
        {
            mult[i][j]=0;
        }

    // Multiplying 1st and 2nd matrix and
    for(i = 0; i < r1; ++i)
        for(j = 0; j < c2; ++j)
            for(k = 0; k < c1; ++k)
            {
                mult[i][j] += a[i][k] * b[k][j];
            }

    // Display the answer
    cout << endl << "Multiplication of the matrix is: " << endl;
    for(i = 0; i < r1; ++i)
    for(j = 0; j < c2; ++j)
    {
        cout << setw(5) << " " << mult[i][j];
        if(j == c2-1)
            cout << endl;
    }
    cout << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Multiplication of the matrix is: " << endl;
        for(i = 0; i < r1; ++i)
        for(j = 0; j < c2; ++j)
        {
        outFile << setw(5) << " " << mult[i][j];
        if(j == c2-1)
            outFile << endl;
        }
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch == 2 )
        {
            menu();
        }
}
//Digital conversion(function)
void digitalConversion()
{
    system("cls");
    int option;
    cout << "Digital Conversion" << endl ;
    cout << "1. Binary to Decimal" << endl;
    cout << "2. Binary to Hexadecimal" << endl;
    cout << "3. Decimal to Binary" << endl;
    cout << "4. Decimal to Hexadecimal" << endl;
    cout << "5. Hexadecimal to Binary" << endl;
    cout << "6. Hexadecimal to Decimal" << endl << endl;
    cout << "Enter you  option: ";
    cin >> option;

    if (option == 1)
    {
    system("cls");
    int decimalNumber = 0, i = 0, remainder;
    int n, p, ch;
    cout << "Enter a binary number: ";
    cin >> n;
    p = n;
    while (n!=0)
    {
        remainder = n%10;
        n /= 10;
        decimalNumber += remainder*pow(2,i);
        ++i;
    }
    cout << p << " in binary = " << decimalNumber << " in decimal";
    cout << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        outFile << p << " in binary = " << decimalNumber << " in decimal";
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
    }
    if (option == 2)
    {
    system("cls");
    long int decnum, rem, quot;
	char hexdecnum[100];
	int i=1, j, temp, ch;
	decnum=decimalConverter();
	quot=decnum;
	while(quot!=0)
	{
		temp=quot%16;
    //Convert integer into character
		if(temp<10)
		{
			temp=temp+48;
		}
		else
		{
			temp=temp+55;
		}
		hexdecnum[i++]=temp;
		quot=quot/16;
	}
	cout << "Equivalent hexadecimal value of " << decnum << " is: ";
	for(j=i-1; j>0; j--)
	{
		cout << hexdecnum[j];
	}
	cout << endl << endl;
	//Saving file
	cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        outFile << "Equivalent hexadecimal value of " << decnum << " is: ";
        for(j=i-1; j>0; j--)
        {
		outFile<<hexdecnum[j];
        }
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
    }
    if (option == 3)
    {
    system("cls");
    int number;
	cout << "Please enter a positive number: ";
	cin >> number;
	if (number < 0)
		cout << "That is not a positive number." << endl;
	else
    {
		cout << number << " Converted to binary is: ";
		binary(number);
		cout << endl;
	}
    }
    if (option == 4)
    {
    system("cls");
    long int decimalNumber,remainder,quotient;
    int i=1,j,temp,ch;
    char hexadecimalNumber[100];

    cout << "Enter any decimal number: ";
    cin >> decimalNumber;

    quotient = decimalNumber;

    while(quotient!=0)
    {
         temp = quotient % 16;

      //convert integer into character
      if( temp < 10)
           temp =temp + 48;
      else
         temp = temp + 55;

      hexadecimalNumber[i++]= temp;
      quotient = quotient / 16;
    }
    cout << "Equivalent hexadecimal number of " << decimalNumber << " is : ";
    for(j = i -1 ;j> 0;j--)
    cout << hexadecimalNumber[j];
    cout << endl << endl;
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        outFile << "Equivalent hexadecimal number of " << decimalNumber << " is : ";
        for(j = i -1 ;j> 0;j--)
        outFile << hexadecimalNumber[j];
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch == 2 )
        {
            menu();
        }
    }
    if (option == 5)
    {
    system("cls");
    char binaryNumber[MAX],hexaDecimal[MAX];
    long int i=0;
    int ch;
    cout << "Enter any hexadecimal number: ";
    cin >> hexaDecimal;

    cout << "Equivalent binary value: ";
    while(hexaDecimal[i])
    {
         switch(hexaDecimal[i])
         {
             case '0': cout<<"0000"; break;
             case '1': cout<<"0001"; break;
             case '2': cout<<"0010"; break;
             case '3': cout<<"0011"; break;
             case '4': cout<<"0100"; break;
             case '5': cout<<"0101"; break;
             case '6': cout<<"0110"; break;
             case '7': cout<<"0111"; break;
             case '8': cout<<"1000"; break;
             case '9': cout<<"1001"; break;
             case 'A': cout<<"1010"; break;
             case 'B': cout<<"1011"; break;
             case 'C': cout<<"1100"; break;
             case 'D': cout<<"1101"; break;
             case 'E': cout<<"1110"; break;
             case 'F': cout<<"1111"; break;
             case 'a': cout<<"1010"; break;
             case 'b': cout<<"1011"; break;
             case 'c': cout<<"1100"; break;
             case 'd': cout<<"1101"; break;
             case 'e': cout<<"1110"; break;
             case 'f': cout<<"1111"; break;
             default:  cout<<"Invalid hexadecimal digit "<<hexaDecimal[i];
         }
         i++;
    }
    //File saving
    cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        outFile << "Equivalent binary value: ";
        while(hexaDecimal[i])
    {
         switch(hexaDecimal[i])
         {
             case '0': outFile << "0000"; break;
             case '1': outFile << "0001"; break;
             case '2': outFile << "0010"; break;
             case '3': outFile << "0011"; break;
             case '4': outFile << "0100"; break;
             case '5': outFile << "0101"; break;
             case '6': outFile << "0110"; break;
             case '7': outFile << "0111"; break;
             case '8': outFile << "1000"; break;
             case '9': outFile << "1001"; break;
             case 'A': outFile << "1010"; break;
             case 'B': outFile << "1011"; break;
             case 'C': outFile << "1100"; break;
             case 'D': outFile << "1101"; break;
             case 'E': outFile << "1110"; break;
             case 'F': outFile << "1111"; break;
             case 'a': outFile << "1010"; break;
             case 'b': outFile << "1011"; break;
             case 'c': outFile << "1100"; break;
             case 'd': outFile << "1101"; break;
             case 'e': outFile << "1110"; break;
             case 'f': outFile << "1111"; break;
             default:  outFile << "Invalid hexadecimal digit " <<hexaDecimal[i];
         }
         i++;
    }
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch == 2 )
        {
            menu();
        }
    }
    if (option == 6)
    {
    system("cls");
    int ch;
    unsigned long decnum;
    char hex[9];     // 8 characters for 32-bit Hexadecimal Number and one for ' '

    cout<<" Enter hexadecimal number : ";
    cin>>hex;

    decnum = convTodecnum(hex);
    cout << "Value in decimal number is " << decnum <<endl;
    cout << endl << endl;
	//Saving file
	cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        outFile << "Value in decimal number is " << decnum <<endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
}
}
//Digital Conversion Calculation
void binary(int number)     //Decimal to binary conversion calculation
{
	int remainder, ch;

	if(number <= 1)
    {
		cout << number;
		return;
	}

	remainder = number%2;
	binary(number >> 1);
	cout << remainder;
	cout << endl << endl;
	//Saving file
	cout << "Enter 1 to save file." << endl;
    cout << "Enter 2 to back to menu." << endl;
    cout << "Enter your choice: ";
    cin >> ch;
    if ( ch == 1)
    {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        outFile << number << " Converted to binary is: ";
        if(number <= 1)
        {
		outFile << number;
		return;
        }
        remainder = number%2;
        binary(number >> 1);
        outFile << remainder;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
    }
        if ( ch ==2 )
        {
            menu();
        }
}

int decimalConverter()
{
    int bin,dec=0,tic,i=0;
    cout<<"Enter the Binary number: ";
    cin>>bin;
    while(bin>0)
    {    tic=bin%10;
         dec=dec+(tic*pow(2,i));
         bin=bin/10;
         i++;
    }
    return dec;
}

unsigned long convTodecnum(char hex[])
{
    char *hexstr;
    int length = 0;
    const int base = 16;     // Base of Hexadecimal Number
    unsigned long decnum = 0;
    int i;

    //Find length of Hexadecimal Number
    for (hexstr = hex; *hexstr != '\0'; hexstr++)
    {
	length++;
    }

    //Find Hexadecimal Number
    hexstr = hex;
    for (i = 0; *hexstr != '\0' && i < length; i++, hexstr++)
    {
	// Compare *hexstr with ASCII values
	if (*hexstr >= 48 && *hexstr <= 57)   // if *hexstr Between 0-9
	{
	    decnum += (((int)(*hexstr)) - 48) * pow(base, length - i - 1);
	}
	else if ((*hexstr >= 65 && *hexstr <= 70))   // if *hexstr Between A-F
	{
	    decnum += (((int)(*hexstr)) - 55) * pow(base, length - i - 1);
	}
	else if (*hexstr >= 97 && *hexstr <= 102)   // if *hexstr Between a-f
	{
	    decnum += (((int)(*hexstr)) - 87) * pow(base, length - i - 1);
	}
	else
	{
	    cout<<"Invalid Hexadecimal Number \n";

	}
    }
    return decnum;
}
//Trigonometric Calculation
void trigoCalc()
{
    system("cls");
    int option, ch;
    cout << "Trigonometric Calculation:" << endl;
    cout << "1. Cosine" << endl;
    cout << "2. Sine" << endl;
    cout << "3. Tangent" << endl;
    cout << "4. Cotangent" << endl;
    cout << "5. Cosecant" << endl;
    cout << "6. Secant" << endl;
    cout << "Enter your option: " ;
    cin >> option;

    if (option == 1)
    {
        system("cls");
        double x, ans, ans1;
        cout << "Enter an integer: ";
        cin >> x;
        ans = x * pi / 180;
        ans1 = cos (ans);
        cout << "Cosine " << x << " is " << ans1;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Cosine " << x << " is " << ans1;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if (option == 2)
    {
        system("cls");
        double x, ans, ch, ans1;
        cout << "Enter an integer: ";
        cin >> x;
        ans = x * pi / 180;
        ans1 = sin (ans);
        cout << "Sine " << x << " is " << ans1;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Sine " << x << " is " << ans1;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if (option == 3)
    {
        system("cls");
        double x, ans, ch, ans1;
        cout << "Enter an integer: ";
        cin >> x;
        ans = x * pi / 180;
        ans1 = tan (ans);
        cout << "Tangent " << x << " is " << ans1;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Tangent " << x << " is " << ans1;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
    if (option == 4)
    {
        system("cls)");
        double x, ans, ch, ans1;
        cout << "Enter an integer: ";
        cin >> x;
        ans = x * pi / 180;
        ans1 = 1/(tan (ans));
        cout << "Cotangent " << x << " is " << ans1;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Cotangent " << x << " is " << ans1;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
    if (option == 5)
    {
        system("cls)");
        double x, ans, ch, ans1;
        cout << "Enter an integer: ";
        cin >> x;
        ans = x * pi / 180;
        ans1 = 1/(sin (ans));
        cout << "Cosecant " << x << " is " << ans1;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Cosecant " << x << " is " << ans1;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if (option == 6)
    {
        system("cls)");
        double x, ans, ch, ans1;
        cout << "Enter an integer: ";
        cin >> x;
        ans = x * pi / 180;
        ans1 = 1/(cos (ans));
        cout << "Secant " << x << " is " << ans1;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Secant " << x << " is " << ans1;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
}
void elecCalc()
{
    system("cls");
    int option;
    cout << "Electrical Calculation" << endl;
    cout << "1. Charge" << endl;
    cout << "2. Capacitance" << endl;
    cout << "3. Current" << endl;
    cout << "4. Voltage" << endl;
    cout << "5. Power" << endl;
    cout << "Enter your option: ";
    cin >> option;

    if ( option == 1)
    {
    system("cls");
    double voltage,capacitance, charge;
    int ch;
    cout << "Charge" << endl;
    cout << "Enter the value of voltage and capacitance." << endl;
    cout << "Voltage: ";
    cin >> voltage;
    cout << "Capacitance: ";
    cin >> capacitance;
    charge = capacitance * voltage;
    cout << "The value of the charge is: " << charge << endl;
    cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The value of the charge is: " << charge << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if ( option == 2)
    {
        double charge,voltage,capacitance;
        int ch;
        system("cls");
        cout << "Capacitance" << endl;
        cout << "Enter the value of the charge and voltage." << endl;
        cout << "Charge: ";
        cin >> charge;
        cout << "Voltage: ";
        cin >> voltage;
        capacitance = charge / voltage;
        cout << "The value of the capacitance is: " << capacitance << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The value of the capacitance is: " << capacitance << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if ( option == 3)
    {
        double voltage,current,resistance;
        int ch;
        system("cls");
        cout << "Current" << endl;
        cout << "Enter the value voltage and resistance." << endl;
        cout << "Voltage: ";
        cin >> voltage;
        cout << "Resistance: ";
        cin >> resistance;
        current = voltage / resistance;
        cout << "The value of current is: " << current << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The value of current is: " << current << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if ( option == 4)
    {
        double voltage,current,resistance;
    int ch;
    system("cls");
    cout << "Voltage" << endl;
    cout << "Enter the value current and resistance." << endl;
    cout << "Current: ";
    cin >> current;
    cout << "Resistance: ";
    cin >> resistance;
    voltage = current * resistance;
    cout << "The value of voltage is: " << voltage << endl;
    cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The value of voltage is: " << voltage << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if ( option == 5)
    {
        double power,voltage,current;
    int ch;
    system("cls");
    cout << "Power" << endl;
    cout << "Enter the value of voltage and current." << endl;
    cout << "Voltage: ";
    cin >> voltage;
    cout << "Current: ";
    cin >> current;
    power = voltage * current;
    cout << "The value of power is: " << power << endl;
    cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "The value of power is: " << power << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
}


//Solid Calculation(structure)
void solidCalc()
{
    system("cls");
    int option;
    cout << "Solid State Calculation" << endl;
    cout << "1. Rectangle" << endl;
    cout << "2. Cube/Cuboid" << endl;
    cout << "3. Circle" << endl;
    cout << "4. Sphere" << endl << endl;
    cout << "Enter your option: " ;
    cin >> option;

    if (option == 1)
    {
        system("cls");
        cout << "Rectangle" << endl;
        side rectangle;
        double perimeter,area;
        int ch;
        cout << "Enter the value of length: ";
        cin >> rectangle.length;
        cout << "Enter the value of height: ";
        cin >> rectangle.height;
        perimeter = (2*rectangle.length) + (2*rectangle.height);
        area = rectangle.length * rectangle.height;
        cout << "Perimeter of the rectangle is " << perimeter << endl;
        cout << "Area of the rectangle is " << area << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Perimeter of the rectangle is " << perimeter << endl;
        outFile << "Area of the rectangle is " << area << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if (option == 2)
    {
        system("cls");
        cout << "Cube/Cuboid" << endl;
        side cuboid;
        double volume,area;
        int ch;
        cout << "Enter the value of length: ";
        cin >> cuboid.length;
        cout << "Enter the value of height: ";
        cin >> cuboid.height;
        cout << "Enter the value of width: ";
        cin >> cuboid.width;
        volume = cuboid.length * cuboid.height * cuboid.width;
        area = (cuboid.length * cuboid.height * 4) + (cuboid.width * cuboid.height * 2);
        cout << "Volume of the cuboid is " << volume << endl;
        cout << "Area of the cuboid is " << area << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Volume of the cuboid is " << volume << endl;
        outFile << "Area of the cuboid is " << area << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if (option == 3)
    {
        system("cls");
        side circle;
        cout << "Circle" << endl;
        double area,circumference;
        int ch;
        cout << "Enter the value of the radius: ";
        cin >> circle.radius;
        circumference = 2*pi*circle.radius;
        area = pi * (pow(circle.radius,2));
        cout << "Circumference of the circle is: " << circumference << endl;
        cout << "Area of the circle is: " << area << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Circumference of the circle is: " << circumference << endl;
        outFile << "Area of the circle is: " << area << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }

    if (option == 4)
    {
        system("cls");
        side sphere;
        cout << "Sphere" << endl;
        double volume;
        int ch;
        cout << "Enter radius of the sphere: ";
        cin >> sphere.radius;
        volume = (4/3)*pi*(pow(sphere.radius,3));
        cout << "Volume of the sphere is: " << volume << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Volume of the sphere is: " << volume << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
}
//Quadratic Equation
void quadraticEquat()
{
    system("cls");
    int a,b,c;
    double x1,x2,x;
    cout << "Please enter the value of a, b and c. " << endl;
    cout << "a: ";
    cin >> a;
    cout << "b: ";
    cin >> b;
    cout << "c: ";
    cin >> c;
    cout << "Your quadratic function is : "<< a << "x^2 + "<< b << "x + " << c << endl;
    cout << "Now this program will finds it root." << endl;
    cout << "Computing roots" << endl;
    for ( int i=0;i<=7;i++)     //delay
    {
        cout << ".";
        Sleep(500);
    }
    cout << endl << endl;
    x = calcX (x1,x2,a,b,c);
}
//Quadratic calculation
double calcX(double x1,double x2,int a,int b,int c)
{
    double p;
    p = (pow(b,2)) - (4*a*c);

    if (p < 0)
    {
        int ch;
        cout << "The function have no roots." << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Your quadratic function is : "<< a << "x^2 + "<< b << "x + " << c << endl;
        outFile << "The function have no roots." << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
    else if(p > 0)
    {
        int ch;
        x1 = (-b + pow(p,0.5))/(2*a);
        x2 = (-b - pow(p,0.5))/(2*a);
        cout << "The roots are: " << x1 << " and " << x2 << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Your quadratic function is : "<< a << "x^2 + "<< b << "x + " << c << endl;
        outFile << "The roots are: " << x1 << " and " << x2 << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
    else if (p == 0)
    {
        int ch;
        cout << "There is one real root" << endl;
        x1 = (-b + pow(p,0.5))/(2*a);
        cout << "The root is: " << x1 << endl;
        cout << endl << endl;
        //Saving File
        cout << "Enter 1 to save file." << endl;
        cout << "Enter 2 to back to menu." << endl;
        cout << "Enter your choice: ";
        cin >> ch;
        if ( ch == 1)
        {
        ofstream outFile;
        string filename;

        cout << "Enter filename: ";
        cin >> filename;
        // Open an output file.
        outFile.open(filename.c_str());
        //Write data into file
        outFile << "Your quadratic function is : "<< a << "x^2 + "<< b << "x + " << c << endl;
        outFile << "There is one real root" << endl;
        outFile << "The root is: " << x1 << endl;
        cout << "Saving file";
        for ( int i=0;i<=5;i++)     //delay
        {
        cout << ".";
        Sleep(500);
        }
        cout << endl;
        cout << "File has been saved." << endl;
        outFile.close();
        menu();
        }
        if ( ch ==2 )
        {
            menu();
        }
    }
}


# data[].attributes.body
Mohd Amri Firzad Bin Mohamad Ariffin
Mohd Che Haziq Bin Che Abang

# data[].attributes.body
FARAH NATASHA BT AZREEN
FATIN AQILAH BT MOHD ISKANDAR

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
#include<fstream>
#define Max 1000
#include<iomanip>
#include<cstdlib>


const double PI = 3.142;

using namespace std;


struct electricCalc //structure for choice number 5
{
  float electricCharge,Capacitance, Current, Voltage, Power;


};

double getInput(double x); //function for number 1
void binary(int); //function for number 3
void findQuadratic1(double &,double &, double&); //function for number 7


int main()
{


    int i,a;
    int row1,row2,col1,col2,element1[100][100],element2[100][100], sum[100][100], sub[100][100], mult[100][100];
    int x,bin;
    char buffer[33];


    cout<<endl<<endl;
    cout<<"\t\t\t Hi welcome to Engineering Calculator!"<<endl;
    cout<<"\t\t\t \4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4"<<endl<<endl;
    cout<<"\t\t 1.Operation of scalar value"<<endl;
    cout<<"\t\t 2.Operation of matrices"<<endl;
    cout<<"\t\t 3.Conversion between Binary, Hexadecimal and Decimal Values"<<endl;
    cout<<"\t\t 4.Operation of Trigonometric"<<endl;
    cout<<"\t\t 5.Operation of electrical value"<<endl;
    cout<<"\t\t 6.Perimeter,Area & Volume of circles and rectangles"<<endl;
    cout<<"\t\t 7.Roots of Quadratic Equation"<<endl;
    cout<<endl<<endl;
    cout<<"\t\t\1 Please choose the operation (1/2/3/4/5/6/7): ";
    cin>>i;
    cout<<endl<<endl;

    if (i==1) //choice number scalar value
    {
        ofstream outfile;
        outfile.open("scalarValue.txt",fstream::app);
        double x,y;
        cout<<"\t\t This choices have four operations of scalar values"<<endl;
        y = getInput(x);
        cout<<"\t\t Your answer is: "<<y<<endl;
        outfile<<y;

    }


    if (i==2)//choice for matrices
    {
        ofstream outfile;
        outfile.open("matrices.txt",fstream::app);
        cout<<"\t\t This choices have three operation of matrices"<<endl<<endl;
        cout<<"\t\t\t 1.Addition"<<endl;
        cout<<"\t\t\t 2.Subtraction"<<endl;
        cout<<"\t\t\t 3.Multiplication"<<endl<<endl;
        cout<<"\t\t\t Please choose operation: ";
        cin>>a;
        cout<<endl<<endl;

        if (a==1)//for addition

        {
            cout<<"Please enter number of rows & column for first matrix separated by space: ";
            cin>>row1>>col1;
            cout<<endl<<endl;
            cout<<"Please enter number of rows & column for second matrix separated by space: ";
            cin>>row2>>col2;
            cout<<endl<<endl;

            while(col1!=col2 || row1!=row2)
            {
                cout<<"\t Error. No of row& column in matrix 1 must equal to matrix 2"<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for first matrix";
                cin>>row1>>col1;
                cout<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for second matrix";
                cin>>row2>>col2;
                cout<<endl<<endl;
            }

        cout<<"\t\t\t Please enter element in matrix 1"<<endl;

        for(int i=0; i<row1; i++)
        {
            for(int j=0; j<col1; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element1[i][j];
                cout<<endl<<endl;
            }
        }

       cout<<"\t\t\t Please enter element in matrix 2"<<endl;

        for(int i=0; i<row2; i++)
        {
            for(int j=0; j<col2; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element2[i][j];
                cout<<endl<<endl;
            }
        }


        for (int i=0;i<row1;i++)
        {
            for(int j=0;j<col2;j++)
            {
                sum[i][j]=0;
            }
        }

       for(int i=0;i<row1;++i)
        {
            for(int j=0;j<col2; ++j)
            {

                sum[i][j] = element1[i][j] + element2[i][j];

            }
        }
        cout <<"\t\t\t Sum of Matrix: " << endl;

        for(int i=0; i<row1;++i)
        {
            for(int j=0; j<col2; ++j)
            {
                cout << "\t\t\t " << sum[i][j];
                outfile<<sum[i][j];
                if(j == col2 - 1)
                cout << endl;

            }
        }
    }
        if (a==2)//for substraction

        {
            cout<<"Please enter number of rows & column for first matrix separated by space: ";
            cin>>row1>>col1;
            cout<<endl<<endl;
            cout<<"Please enter number of rows & column for second matrix separated by space: ";
            cin>>row2>>col2;
            cout<<endl<<endl;

            while(col1!=col2 || row1!=row2)
            {
                cout<<"\t Error. No of row& column in matrix 1 must equal to matrix 2"<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for first matrix";
                cin>>row1>>col1;
                cout<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for second matrix";
                cin>>row2>>col2;
                cout<<endl<<endl;
            }

        cout<<"\t\t\t Please enter element in matrix 1"<<endl;

        for(int i=0; i<row1; i++)
        {
            for(int j=0; j<col1; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element1[i][j];
                cout<<endl<<endl;
            }
        }

       cout<<"\t\t\t Please enter element in matrix 2"<<endl;

        for(int i=0; i<row2; i++)
        {
            for(int j=0; j<col2; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element2[i][j];
                cout<<endl<<endl;
            }
        }


        for (int i=0;i<row1;i++)
        {
            for(int j=0;j<col2;j++)
            {
                sub[i][j]=0;
            }
        }

       for(int i=0;i<row1;++i)
        {
            for(int j=0;j<col2; ++j)
            {

                sub[i][j] = element1[i][j] - element2[i][j];

            }
        }
        cout <<"\t\t\t Subtraction of Matrix: " << endl;

        for(int i=0; i<row1;++i)
        {
            for(int j=0; j<col2; ++j)
            {
                cout << "\t\t\t " << sub[i][j];
                outfile<<sub[i][j];
                if(j == col2 - 1)
                cout << endl;

            }
        }
    }
        if (a==3) //for multiplication

        {
            cout<<"Please enter number of rows & column for first matrix separated by space: ";
            cin>>row1>>col1;
            cout<<endl<<endl;
            cout<<"Please enter number of rows & column for second matrix separated by space: ";
            cin>>row2>>col2;
            cout<<endl<<endl;

            while(col1!=row2)
            {
                cout<<"\t Error. No of column in matrix 1 must equal No of row in matrix 2"<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for first matrix";
                cin>>row1>>col1;
                cout<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for second matrix";
                cin>>row2>>col2;
                cout<<endl<<endl;
            }

            cout<<"\t\t\t Please enter element in matrix 1"<<endl;

            for(int i=0; i<row1; i++)
            {
                for(int j=0; j<col1; j++)
                {
                    cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                    cin>>element1[i][j];
                    cout<<endl<<endl;
                }
            }

            cout<<"\t\t\t Please enter element in matrix 2"<<endl;

            for(int i=0; i<row2; i++)
            {
                for(int j=0; j<col2; j++)
                {
                    cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                    cin>>element2[i][j];
                    cout<<endl<<endl;
                }
            }


            for (int i=0;i<row1;i++)
            {
                for(int j=0;j<col2;j++)
                {
                    mult[i][j]=0;
                }
            }

            for(int i=0;i<row1;i++)
            {
                for(int j=0;j<col2; j++)
                {
                    for(int c=0; c<col1; c++)

                    mult[i][j] += element1[i][c] * element2[c][j];
                }
            }
            cout <<"\t\t\t Multiplication of Matrix: " << endl;

            for(int i=0; i<row1;i++)
            {
                for(int j=0; j<col2; j++)
                {
                    cout << "\t\t\t " << mult[i][j];
                    outfile<<mult[i][j];
                    if(j == col2 - 1)
                    cout << endl;
                }
            }
        }

    outfile.close();

    }


    if (i==3)//choice for conversion
    {
        ofstream outfile;
        outfile.open("conversion.txt",fstream::app);
        int a;
        cout<<"\t\t\t This choices have six conversions"<<endl<<endl;
        cout<<"\t\t\t 1.binary to decimal "<<endl;
        cout<<"\t\t\t 2.binary to Hexadecimal"<<endl;
        cout<<"\t\t\t 3.Decimal to Binary"<<endl;
        cout<<"\t\t\t 4.Decimal to Hexadecimal"<<endl;
        cout<<"\t\t\t 5.Hexadecimal to binary"<<endl;
        cout<<"\t\t\t 6.Hexadecimal to Decimal"<<endl<<endl;
        cout<<"\t\t\t What do you want to convert?: ";
        cin>>a;
        cout<<endl<<endl;

        if(a==1)
        {
            long bin,dec=0,rem,num,base=1;
            cout<<"\t\t\t Enter binary number:";
            cin>>num;
            cout<<endl<<endl;
            bin=num;

            while(num>0)
            {
                rem=num%10;
                dec=dec+rem*base;
                base=base*2;
                num=num/10;
            }
            cout<<"\t\t\t The decimal is:"<<dec;
            outfile<<dec;
            cout<<endl<<endl;

        }

        if(a==2)
        {
            char binNum[Max],hexa[Max];
            int temp,i=0,j=0;

            cout<<"\t\t\t Please enter your Binary Number:";
            cin>>binNum;
            cout<<endl<<endl;


            while (binNum[i])
            {
                binNum[i]= binNum[i]-48;
                ++i;

            }
            --i;
            while (i-2>=0)
            {
                temp= (binNum[i-3]*8)+(binNum[i-2]*4)+(binNum[i-1]*2)+binNum[i];

                if (temp>9)
                    hexa[j++] = temp+55;
                else
                    hexa[j++] = temp+48;

                i=i-4;

            }

            if(i==1)
                hexa[j] = (binNum[i-1]*2)+(binNum[i])+ 48;

            else if(i==0)
                hexa[j]=binNum[i]+48;

            else
                --j;
                cout<<"\t\t\t The Hexadecimal number is:";

            while(j>=0)
            {
                cout<<hexa[j--]<<endl;
                outfile<<hexa[j--];

            }
        }

        if(a==3)
        {
                int x,bin;
                char buffer[33];
                cout<<"\t\t\t Enter decimal number:";
                cin>>x;
                cout<<endl<<endl;

                if(x<0)
                {
                    cout<<x<<"\t\t\t not possible!!";
                }
                else
                {
                    cout<<endl;
                    cout<<"\t\t\t The binary is:";
                    binary(x);
                    cout<<endl;
                }
            }
        if(a==4)
        {
            int i;
            cout<<"\t\t\t Enter decimal number:";
            cin>>i;
            cout<<endl<<endl;
            cout<<"\t\t\t The hexa number is:" <<hex<<i;
            outfile<<hex;

        }

        if(a==5)
        {
            char binNum[Max],hexNum[Max];
            long int i=0;

            cout<<"\t\t\t Enter hexadecimal number:";
            cin>>hexNum;
            cout<<endl<<endl;
            cout<<"\t\t\t The binary number is:";

            while(hexNum[i])
            {
                switch(hexNum[i])
                {
                    case'0':cout<<"0000";break;
                    case'1':cout<<"0001";break;
                    case'2':cout<<"0010";break;
                    case'3':cout<<"0011";break;
                    case'4':cout<<"0100";break;
                    case'5':cout<<"0101";break;
                    case'6':cout<<"0110";break;
                    case'7':cout<<"0111";break;
                    case'8':cout<<"1000";break;
                    case'9':cout<<"1001";break;
                    case'A':cout<<"1010";break;
                    case'B':cout<<"1011";break;
                    case'C':cout<<"1100";break;
                    case'D':cout<<"1101";break;
                    case'E':cout<<"1110";break;
                    case'F':cout<<"1111";break;

                    default:cout<<"\t\t\t Invalid hexadecimal number"<<hexNum[i];
                    outfile<<hexNum[i];

                }
                i++;
            }
        }

        if(a==6)
        {
            int dec;

            cout<<"\t\t\t Enter Hex number:";
            cin>>hex>>dec;
            cout<<"\t\t\t The answer is "<<dec<<endl;
            outfile<<dec;

        }
        outfile.close();
    }

    if (i==4)//choice for trigonometric
    {
            ofstream outfile;
            outfile.open("trigonometric.txt",fstream::app);
            double a, b, c, d, e, f, g, h, i, j, degrees, radians, data,x;

            cout<<"\t\t This choices have 6 trigonometric operation"<<endl<<endl;
            cout<<"\t 1.Convert [degree->radian] or [radian->degree]"<<endl<<endl;
            cout<<"\t 2.Solve [cosine], [sine], [tangent]"<<endl<<endl;
            cout<<"\t\t Choose your operation: ";

            cin>>a;

            if (a==1)//conversion degree&radian
            {
                cout<<"\t\t 1.DEGREE->RADIAN"<<endl;
                cout<<"\t\t 2.RADIAN->DEGREE"<<endl;
                cout<<"\t\t Choose your operation: ";
                cin>>b;



                if (b==1)//degree to radian
                {
                    cout<<"\t\t Please enter your degrees value: ";
                    cin>>c;
                    radians= (PI/180)*c;
                    cout<<"\t\t " <<c<<" degree value in radian is: "<<radians;
                    outfile<<radians;
                }

                if (b==2)//radian to degree
                {
                    cout<<"\t\t Please enter your radians value: ";
                    cin>>d;
                    degrees= (180/PI)*d;
                    cout<<"\t\t "<<d<<" radian value in degree is: "<<degrees;
                    outfile<<degrees;
                }
            }

            if (a==2)//trigonometric
            {

                cout<<"\t\t What type data you want to enter?"<<endl<<endl;
                cout<<"\t\t\t  1.data in degree"<<endl;
                cout<<"\t\t\t  2.data in radian"<<endl;
                cout<<"\t\t  Please choose: ";
                cin>> data;
                cout<<endl<<endl;

                if (data==1)
                {
                    cout<<"\t\t Please enter the value of x (example: cos 'x') (in degree): ";
                    cin>>x;
                    cout<<endl<<endl;
                    e = (PI/180)*x;
                    f = cos (e);
                    g = sin (e);
                    h = tan (e);
                    cout<<"\t\t\t 1.cos "<<x<<" is "<< f << endl;
                    cout<<"\t\t\t 2.sin "<<x<<" is "<< g << endl;
                    cout<<"\t\t\t 3.tan "<<x<<" is "<< h << endl;

                }

                if (data==2)
                {
                    cout<<"\t\t Please enter the value of x (example: cos 'x')(in radian): ";
                    cin>>x;
                    cout<<endl<<endl;
                    f = cos (x);
                    g = sin (x);
                    h = tan (x);
                    cout<<"\t\t\t 1.cos "<<x<<" is "<< f << endl;
                    cout<<"\t\t\t 2.sin "<<x<<" is "<< g << endl;
                    cout<<"\t\t\t 3.tan "<<x<<" is "<< h << endl;

                }






            }

outfile.close();
    }

    if (i==5)//electrical parameter
            {
                ofstream outfile;
                outfile.open("electrical.txt",fstream::app);
                int a;
                electricCalc c,v,q,i,p;
                cout<<"\t\t\t 1.Electrical charge"<<endl;
                cout<<"\t\t\t 2.Capacitance"<<endl;
                cout<<"\t\t\t 3.Current"<<endl;
                cout<<"\t\t\t 4.Voltage"<<endl;
                cout<<"\t\t\t 5.Power"<<endl<<endl;
                cout<<"\t\t\t What do you want to calculate:";
                cin>>a;

                if (a==1)//electrical charge
                {
                    cout<<"\t\t Enter your capacitance and voltage value: ";
                    cin>>c.Capacitance>>v.Voltage;
                    cout<<"\t\t\t Your electrical charge is: "<< (c.Capacitance)*(v.Voltage)<<endl;
                    outfile<<(c.Capacitance*(v.Voltage));
                }
                else if (a==2)//capacitance
                {
                    cout<<"\t\t Enter your electrical charge and voltage value: ";
                    cin>>q.electricCharge>>v.Voltage;
                    cout<<"\t\t\t Your electrical capacitance is: "<< q.electricCharge/v.Voltage <<endl;
                    outfile<<((q.electricCharge)/(v.Voltage));

                }

                else if (a==3)//current
                {
                    cout<<"\t\t Enter your power and voltage value: ";
                    cin>>p.Power>>v.Voltage;
                    cout<<"\t\t\t Your electrical current is: "<< p.Power/v.Voltage <<endl;
                    outfile<<((p.Power/v.Voltage ));
                }

                else if (a==4)//voltage
                {
                    cout<<"\t\t Enter your power and current value: ";
                    cin>>p.Power>>i.Current;
                    cout<<"\t\t\t Your electrical voltage is: "<< p.Power/i.Current <<endl;
                    outfile<<((p.Power/i.Current ));
                }

                else if (a==5)//power
                {
                    cout<<"\t\t Enter your voltage and current value: ";
                    cin>>v.Voltage>>i.Current;
                    cout<<"\t\t\t Your electrical power is: "<<v.Voltage*i.Current<<endl;
                    outfile<<((v.Voltage*i.Current ));
                }

outfile.close();

    }

    if (i==6)//choice for calculate circle or rectangle
    {
         ofstream outfile;
         outfile.open("circlerectangle.txt",fstream::app);
         int a;
         double radius,length, width, height, Perimeter, Area, Volume;
         cout<<"\t\t\t 1.Circle"<<endl;
         cout<<"\t\t\t 2.Rectangle"<<endl;
         cout<<"\t\t\t Please choose by enter the number(1/2)";
         cin>>a;
         cout<<endl;

        if(a==1)//circle
        {
            cout<<"\t\t\t Please enter the value of radius of your circle: ";
            cin>>radius;
            Perimeter= 2*PI*radius;
            Area= PI*pow(radius,2);
            Volume= (4/3)*PI*pow(radius,3);
        }

        if(a==2)//rectangle
        {
            cout<<"\t\t Please enter you length, width and height of your rectangular: "<<endl;
            cout<<"\t\t\t";
            cin>>length>>width>>height;
            cout<<endl<<endl;
            Perimeter= (length*2)+(width*2);
            Area= length*width;
            Volume= length*width*height;
        }

        cout<<"\t\t\t Your Perimeter is: " <<Perimeter<<endl;
        cout<<"\t\t\t Your Area is: "<<Area<<endl;
        cout<<"\t\t\t Your Volume is: "<<Volume<<endl;
        outfile<<Perimeter<<Area<<Volume;

outfile.close();
   }

    if (i==7)//choice for quadratic equation
    {
        double a, b, c, x1, x2, x3;
        cout<<"\t\tYou have chose to find roots of quadratic equation"<<endl;
        cout<<"\t\tPlease enter your a, b, and c value: ";
        cin>>a>>b>>c;


        findQuadratic1(a,b,c);
    }




return 0;
}

double getInput(double x) //for number 1

{

    double b,c,operate,first, second, total=0;

    cout<<"\t\t 1.Addition,2.Substraction,3.Multiplication,4.Division"<<endl<<endl;
    cout<<"\t\t Please choose your operation: ";
    cin>>operate;
    cout<<endl<<endl;

    if(operate==1)//addition
    {

        cout<<"\t\t Enter how many values you want to add: ";
        cin>>b;
        cout<<endl<<endl;

        for (int a=1; a<=b; a++)
        {
            cout<<"\t\t Please enter value number "<<a<<" : ";
            cin>>c;
            cout<<endl<<endl;
            total+=c;

        }
    }

    if(operate==2)//substraction
    {
        cout<<"\t\t\t Enter your first number:";
        cin>>first;
        cout<<endl<<endl;
        cout<<"\t\t\t Enter your second number:";
        cin>>second;
        cout<<endl;

        total= (first-second);
    }


    if(operate==3)//multiplication
    {
        cout<<"\t\t\t Enter your first number:";
        cin>>first;
        cout<<endl<<endl;
        cout<<"\t\t\t Enter your second number:";
        cin>>second;
        cout<<endl;

        total= (first*second);
    }

    if(operate==4)//division
    {
        cout<<"\t\t\t Enter your first number:";
        cin>>first;
        cout<<endl<<endl;
        cout<<"\t\t\t Enter your second number:";
        cin>>second;
        cout<<endl;
        total=first/second;
    }

    return total;

}

void binary(int num) //for number 3
{
    ofstream outfile;
    outfile.open("conversion.txt",fstream::app);
    int rem;

    if (num<=1)
    {
        cout<<" "<<num;
        outfile<<num;
        return;
    }
    rem=num%2;
    binary(num/2);
    cout<<" "<< rem;
    outfile<<rem;

    outfile.close();


}

void findQuadratic1(double &x,double &y, double &z) //for number 7
{
    ofstream outfile;
    outfile.open("quadratic.txt",fstream::app);
    double f,i,j,x1,x2,x3;

    f = pow(y,2);
    i = f-(4*x*z);
    j = abs(i);
    x1 = sqrt(j)+(-y)/(2)*x;
    x2 = -y -(sqrt(j))/(2)*x;
    cout<<"\t\t\t The value of x is: "<<x1<<" , "<<x2;
    outfile<<x1<<x2;

    outfile.close();
}






# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
#include<fstream>
#define Max 1000
#include<iomanip>
#include<cstdlib>


const double PI = 3.142;

using namespace std;


struct electricCalc //structure for choice number 5
{
  float electricCharge,Capacitance, Current, Voltage, Power;


};

double getInput(double x); //function for number 1
void binary(int); //function for number 3
void findQuadratic1(double &,double &, double&); //function for number 7


int main()
{


    int i,a;
    int row1,row2,col1,col2,element1[100][100],element2[100][100], sum[100][100], sub[100][100], mult[100][100];
    int x,bin;
    char buffer[33];


    cout<<endl<<endl;
    cout<<"\t\t\t Hi welcome to Engineering Calculator!"<<endl;
    cout<<"\t\t\t \4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4"<<endl<<endl;
    cout<<"\t\t 1.Operation of scalar value"<<endl;
    cout<<"\t\t 2.Operation of matrices"<<endl;
    cout<<"\t\t 3.Conversion between Binary, Hexadecimal and Decimal Values"<<endl;
    cout<<"\t\t 4.Operation of Trigonometric"<<endl;
    cout<<"\t\t 5.Operation of electrical value"<<endl;
    cout<<"\t\t 6.Perimeter,Area & Volume of circles and rectangles"<<endl;
    cout<<"\t\t 7.Roots of Quadratic Equation"<<endl;
    cout<<endl<<endl;
    cout<<"\t\t\1 Please choose the operation (1/2/3/4/5/6/7): ";
    cin>>i;
    cout<<endl<<endl;

    if (i==1) //choice number scalar value
    {
        ofstream outfile;
        outfile.open("scalarValue.txt",fstream::app);
        double x,y;
        cout<<"\t\t This choices have four operations of scalar values"<<endl;
        y = getInput(x);
        cout<<"\t\t Your answer is: "<<y<<endl;
        outfile<<y;

    }


    if (i==2)//choice for matrices
    {
        ofstream outfile;
        outfile.open("matrices.txt",fstream::app);
        cout<<"\t\t This choices have three operation of matrices"<<endl<<endl;
        cout<<"\t\t\t 1.Addition"<<endl;
        cout<<"\t\t\t 2.Subtraction"<<endl;
        cout<<"\t\t\t 3.Multiplication"<<endl<<endl;
        cout<<"\t\t\t Please choose operation: ";
        cin>>a;
        cout<<endl<<endl;

        if (a==1)//for addition

        {
            cout<<"Please enter number of rows & column for first matrix separated by space: ";
            cin>>row1>>col1;
            cout<<endl<<endl;
            cout<<"Please enter number of rows & column for second matrix separated by space: ";
            cin>>row2>>col2;
            cout<<endl<<endl;

            while(col1!=col2 || row1!=row2)
            {
                cout<<"\t Error. No of row& column in matrix 1 must equal to matrix 2"<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for first matrix";
                cin>>row1>>col1;
                cout<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for second matrix";
                cin>>row2>>col2;
                cout<<endl<<endl;
            }

        cout<<"\t\t\t Please enter element in matrix 1"<<endl;

        for(int i=0; i<row1; i++)
        {
            for(int j=0; j<col1; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element1[i][j];
                cout<<endl<<endl;
            }
        }

       cout<<"\t\t\t Please enter element in matrix 2"<<endl;

        for(int i=0; i<row2; i++)
        {
            for(int j=0; j<col2; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element2[i][j];
                cout<<endl<<endl;
            }
        }


        for (int i=0;i<row1;i++)
        {
            for(int j=0;j<col2;j++)
            {
                sum[i][j]=0;
            }
        }

       for(int i=0;i<row1;++i)
        {
            for(int j=0;j<col2; ++j)
            {

                sum[i][j] = element1[i][j] + element2[i][j];

            }
        }
        cout <<"\t\t\t Sum of Matrix: " << endl;

        for(int i=0; i<row1;++i)
        {
            for(int j=0; j<col2; ++j)
            {
                cout << "\t\t\t " << sum[i][j];
                outfile<<sum[i][j];
                if(j == col2 - 1)
                cout << endl;

            }
        }
    }
        if (a==2)//for substraction

        {
            cout<<"Please enter number of rows & column for first matrix separated by space: ";
            cin>>row1>>col1;
            cout<<endl<<endl;
            cout<<"Please enter number of rows & column for second matrix separated by space: ";
            cin>>row2>>col2;
            cout<<endl<<endl;

            while(col1!=col2 || row1!=row2)
            {
                cout<<"\t Error. No of row& column in matrix 1 must equal to matrix 2"<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for first matrix";
                cin>>row1>>col1;
                cout<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for second matrix";
                cin>>row2>>col2;
                cout<<endl<<endl;
            }

        cout<<"\t\t\t Please enter element in matrix 1"<<endl;

        for(int i=0; i<row1; i++)
        {
            for(int j=0; j<col1; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element1[i][j];
                cout<<endl<<endl;
            }
        }

       cout<<"\t\t\t Please enter element in matrix 2"<<endl;

        for(int i=0; i<row2; i++)
        {
            for(int j=0; j<col2; j++)
            {
                cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                cin>>element2[i][j];
                cout<<endl<<endl;
            }
        }


        for (int i=0;i<row1;i++)
        {
            for(int j=0;j<col2;j++)
            {
                sub[i][j]=0;
            }
        }

       for(int i=0;i<row1;++i)
        {
            for(int j=0;j<col2; ++j)
            {

                sub[i][j] = element1[i][j] - element2[i][j];

            }
        }
        cout <<"\t\t\t Subtraction of Matrix: " << endl;

        for(int i=0; i<row1;++i)
        {
            for(int j=0; j<col2; ++j)
            {
                cout << "\t\t\t " << sub[i][j];
                outfile<<sub[i][j];
                if(j == col2 - 1)
                cout << endl;

            }
        }
    }
        if (a==3) //for multiplication

        {
            cout<<"Please enter number of rows & column for first matrix separated by space: ";
            cin>>row1>>col1;
            cout<<endl<<endl;
            cout<<"Please enter number of rows & column for second matrix separated by space: ";
            cin>>row2>>col2;
            cout<<endl<<endl;

            while(col1!=row2)
            {
                cout<<"\t Error. No of column in matrix 1 must equal No of row in matrix 2"<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for first matrix";
                cin>>row1>>col1;
                cout<<endl<<endl;
                cout<<"\t\t\t Please enter number of rows & column for second matrix";
                cin>>row2>>col2;
                cout<<endl<<endl;
            }

            cout<<"\t\t\t Please enter element in matrix 1"<<endl;

            for(int i=0; i<row1; i++)
            {
                for(int j=0; j<col1; j++)
                {
                    cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                    cin>>element1[i][j];
                    cout<<endl<<endl;
                }
            }

            cout<<"\t\t\t Please enter element in matrix 2"<<endl;

            for(int i=0; i<row2; i++)
            {
                for(int j=0; j<col2; j++)
                {
                    cout<<"\t\t\t Enter element for row "<<i+1<<" and column "<<j+1<<" : ";
                    cin>>element2[i][j];
                    cout<<endl<<endl;
                }
            }


            for (int i=0;i<row1;i++)
            {
                for(int j=0;j<col2;j++)
                {
                    mult[i][j]=0;
                }
            }

            for(int i=0;i<row1;i++)
            {
                for(int j=0;j<col2; j++)
                {
                    for(int c=0; c<col1; c++)

                    mult[i][j] += element1[i][c] * element2[c][j];
                }
            }
            cout <<"\t\t\t Multiplication of Matrix: " << endl;

            for(int i=0; i<row1;i++)
            {
                for(int j=0; j<col2; j++)
                {
                    cout << "\t\t\t " << mult[i][j];
                    outfile<<mult[i][j];
                    if(j == col2 - 1)
                    cout << endl;
                }
            }
        }

    outfile.close();

    }


    if (i==3)//choice for conversion
    {
        ofstream outfile;
        outfile.open("conversion.txt",fstream::app);
        int a;
        cout<<"\t\t\t This choices have six conversions"<<endl<<endl;
        cout<<"\t\t\t 1.binary to decimal "<<endl;
        cout<<"\t\t\t 2.binary to Hexadecimal"<<endl;
        cout<<"\t\t\t 3.Decimal to Binary"<<endl;
        cout<<"\t\t\t 4.Decimal to Hexadecimal"<<endl;
        cout<<"\t\t\t 5.Hexadecimal to binary"<<endl;
        cout<<"\t\t\t 6.Hexadecimal to Decimal"<<endl<<endl;
        cout<<"\t\t\t What do you want to convert?: ";
        cin>>a;
        cout<<endl<<endl;

        if(a==1)
        {
            long bin,dec=0,rem,num,base=1;
            cout<<"\t\t\t Enter binary number:";
            cin>>num;
            cout<<endl<<endl;
            bin=num;

            while(num>0)
            {
                rem=num%10;
                dec=dec+rem*base;
                base=base*2;
                num=num/10;
            }
            cout<<"\t\t\t The decimal is:"<<dec;
            outfile<<dec;
            cout<<endl<<endl;

        }

        if(a==2)
        {
            char binNum[Max],hexa[Max];
            int temp,i=0,j=0;

            cout<<"\t\t\t Please enter your Binary Number:";
            cin>>binNum;
            cout<<endl<<endl;


            while (binNum[i])
            {
                binNum[i]= binNum[i]-48;
                ++i;

            }
            --i;
            while (i-2>=0)
            {
                temp= (binNum[i-3]*8)+(binNum[i-2]*4)+(binNum[i-1]*2)+binNum[i];

                if (temp>9)
                    hexa[j++] = temp+55;
                else
                    hexa[j++] = temp+48;

                i=i-4;

            }

            if(i==1)
                hexa[j] = (binNum[i-1]*2)+(binNum[i])+ 48;

            else if(i==0)
                hexa[j]=binNum[i]+48;

            else
                --j;
                cout<<"\t\t\t The Hexadecimal number is:";

            while(j>=0)
            {
                cout<<hexa[j--]<<endl;
                outfile<<hexa[j--];

            }
        }

        if(a==3)
        {
                int x,bin;
                char buffer[33];
                cout<<"\t\t\t Enter decimal number:";
                cin>>x;
                cout<<endl<<endl;

                if(x<0)
                {
                    cout<<x<<"\t\t\t not possible!!";
                }
                else
                {
                    cout<<endl;
                    cout<<"\t\t\t The binary is:";
                    binary(x);
                    cout<<endl;
                }
            }
        if(a==4)
        {
            int i;
            cout<<"\t\t\t Enter decimal number:";
            cin>>i;
            cout<<endl<<endl;
            cout<<"\t\t\t The hexa number is:" <<hex<<i;
            outfile<<hex;

        }

        if(a==5)
        {
            char binNum[Max],hexNum[Max];
            long int i=0;

            cout<<"\t\t\t Enter hexadecimal number:";
            cin>>hexNum;
            cout<<endl<<endl;
            cout<<"\t\t\t The binary number is:";

            while(hexNum[i])
            {
                switch(hexNum[i])
                {
                    case'0':cout<<"0000";break;
                    case'1':cout<<"0001";break;
                    case'2':cout<<"0010";break;
                    case'3':cout<<"0011";break;
                    case'4':cout<<"0100";break;
                    case'5':cout<<"0101";break;
                    case'6':cout<<"0110";break;
                    case'7':cout<<"0111";break;
                    case'8':cout<<"1000";break;
                    case'9':cout<<"1001";break;
                    case'A':cout<<"1010";break;
                    case'B':cout<<"1011";break;
                    case'C':cout<<"1100";break;
                    case'D':cout<<"1101";break;
                    case'E':cout<<"1110";break;
                    case'F':cout<<"1111";break;

                    default:cout<<"\t\t\t Invalid hexadecimal number"<<hexNum[i];
                    outfile<<hexNum[i];

                }
                i++;
            }
        }

        if(a==6)
        {
            int dec;

            cout<<"\t\t\t Enter Hex number:";
            cin>>hex>>dec;
            cout<<"\t\t\t The answer is "<<dec<<endl;
            outfile<<dec;

        }
        outfile.close();
    }

    if (i==4)//choice for trigonometric
    {
            ofstream outfile;
            outfile.open("trigonometric.txt",fstream::app);
            double a, b, c, d, e, f, g, h, i, j, degrees, radians, data,x;

            cout<<"\t\t This choices have 6 trigonometric operation"<<endl<<endl;
            cout<<"\t 1.Convert [degree->radian] or [radian->degree]"<<endl<<endl;
            cout<<"\t 2.Solve [cosine], [sine], [tangent]"<<endl<<endl;
            cout<<"\t\t Choose your operation: ";

            cin>>a;

            if (a==1)//conversion degree&radian
            {
                cout<<"\t\t 1.DEGREE->RADIAN"<<endl;
                cout<<"\t\t 2.RADIAN->DEGREE"<<endl;
                cout<<"\t\t Choose your operation: ";
                cin>>b;



                if (b==1)//degree to radian
                {
                    cout<<"\t\t Please enter your degrees value: ";
                    cin>>c;
                    radians= (PI/180)*c;
                    cout<<"\t\t " <<c<<" degree value in radian is: "<<radians;
                    outfile<<radians;
                }

                if (b==2)//radian to degree
                {
                    cout<<"\t\t Please enter your radians value: ";
                    cin>>d;
                    degrees= (180/PI)*d;
                    cout<<"\t\t "<<d<<" radian value in degree is: "<<degrees;
                    outfile<<degrees;
                }
            }

            if (a==2)//trigonometric
            {

                cout<<"\t\t What type data you want to enter?"<<endl<<endl;
                cout<<"\t\t\t  1.data in degree"<<endl;
                cout<<"\t\t\t  2.data in radian"<<endl;
                cout<<"\t\t  Please choose: ";
                cin>> data;
                cout<<endl<<endl;

                if (data==1)
                {
                    cout<<"\t\t Please enter the value of x (example: cos 'x') (in degree): ";
                    cin>>x;
                    cout<<endl<<endl;
                    e = (PI/180)*x;
                    f = cos (e);
                    g = sin (e);
                    h = tan (e);
                    cout<<"\t\t\t 1.cos "<<x<<" is "<< f << endl;
                    cout<<"\t\t\t 2.sin "<<x<<" is "<< g << endl;
                    cout<<"\t\t\t 3.tan "<<x<<" is "<< h << endl;

                }

                if (data==2)
                {
                    cout<<"\t\t Please enter the value of x (example: cos 'x')(in radian): ";
                    cin>>x;
                    cout<<endl<<endl;
                    f = cos (x);
                    g = sin (x);
                    h = tan (x);
                    cout<<"\t\t\t 1.cos "<<x<<" is "<< f << endl;
                    cout<<"\t\t\t 2.sin "<<x<<" is "<< g << endl;
                    cout<<"\t\t\t 3.tan "<<x<<" is "<< h << endl;

                }






            }

outfile.close();
    }

    if (i==5)//electrical parameter
            {
                ofstream outfile;
                outfile.open("electrical.txt",fstream::app);
                int a;
                electricCalc c,v,q,i,p;
                cout<<"\t\t\t 1.Electrical charge"<<endl;
                cout<<"\t\t\t 2.Capacitance"<<endl;
                cout<<"\t\t\t 3.Current"<<endl;
                cout<<"\t\t\t 4.Voltage"<<endl;
                cout<<"\t\t\t 5.Power"<<endl<<endl;
                cout<<"\t\t\t What do you want to calculate:";
                cin>>a;

                if (a==1)//electrical charge
                {
                    cout<<"\t\t Enter your capacitance and voltage value: ";
                    cin>>c.Capacitance>>v.Voltage;
                    cout<<"\t\t\t Your electrical charge is: "<< (c.Capacitance)*(v.Voltage)<<endl;
                    outfile<<(c.Capacitance*(v.Voltage));
                }
                else if (a==2)//capacitance
                {
                    cout<<"\t\t Enter your electrical charge and voltage value: ";
                    cin>>q.electricCharge>>v.Voltage;
                    cout<<"\t\t\t Your electrical capacitance is: "<< q.electricCharge/v.Voltage <<endl;
                    outfile<<((q.electricCharge)/(v.Voltage));

                }

                else if (a==3)//current
                {
                    cout<<"\t\t Enter your power and voltage value: ";
                    cin>>p.Power>>v.Voltage;
                    cout<<"\t\t\t Your electrical current is: "<< p.Power/v.Voltage <<endl;
                    outfile<<((p.Power/v.Voltage ));
                }

                else if (a==4)//voltage
                {
                    cout<<"\t\t Enter your power and current value: ";
                    cin>>p.Power>>i.Current;
                    cout<<"\t\t\t Your electrical voltage is: "<< p.Power/i.Current <<endl;
                    outfile<<((p.Power/i.Current ));
                }

                else if (a==5)//power
                {
                    cout<<"\t\t Enter your voltage and current value: ";
                    cin>>v.Voltage>>i.Current;
                    cout<<"\t\t\t Your electrical power is: "<<v.Voltage*i.Current<<endl;
                    outfile<<((v.Voltage*i.Current ));
                }

outfile.close();

    }

    if (i==6)//choice for calculate circle or rectangle
    {
         ofstream outfile;
         outfile.open("circlerectangle.txt",fstream::app);
         int a;
         double radius,length, width, height, Perimeter, Area, Volume;
         cout<<"\t\t\t 1.Circle"<<endl;
         cout<<"\t\t\t 2.Rectangle"<<endl;
         cout<<"\t\t\t Please choose by enter the number(1/2)";
         cin>>a;
         cout<<endl;

        if(a==1)//circle
        {
            cout<<"\t\t\t Please enter the value of radius of your circle: ";
            cin>>radius;
            Perimeter= 2*PI*radius;
            Area= PI*pow(radius,2);
            Volume= (4/3)*PI*pow(radius,3);
        }

        if(a==2)//rectangle
        {
            cout<<"\t\t Please enter you length, width and height of your rectangular: "<<endl;
            cout<<"\t\t\t";
            cin>>length>>width>>height;
            cout<<endl<<endl;
            Perimeter= (length*2)+(width*2);
            Area= length*width;
            Volume= length*width*height;
        }

        cout<<"\t\t\t Your Perimeter is: " <<Perimeter<<endl;
        cout<<"\t\t\t Your Area is: "<<Area<<endl;
        cout<<"\t\t\t Your Volume is: "<<Volume<<endl;
        outfile<<Perimeter<<Area<<Volume;

outfile.close();
   }

    if (i==7)//choice for quadratic equation
    {
        double a, b, c, x1, x2, x3;
        cout<<"\t\tYou have chose to find roots of quadratic equation"<<endl;
        cout<<"\t\tPlease enter your a, b, and c value: ";
        cin>>a>>b>>c;


        findQuadratic1(a,b,c);
    }




return 0;
}

double getInput(double x) //for number 1

{

    double b,c,operate,first, second, total=0;

    cout<<"\t\t 1.Addition,2.Substraction,3.Multiplication,4.Division"<<endl<<endl;
    cout<<"\t\t Please choose your operation: ";
    cin>>operate;
    cout<<endl<<endl;

    if(operate==1)//addition
    {

        cout<<"\t\t Enter how many values you want to add: ";
        cin>>b;
        cout<<endl<<endl;

        for (int a=1; a<=b; a++)
        {
            cout<<"\t\t Please enter value number "<<a<<" : ";
            cin>>c;
            cout<<endl<<endl;
            total+=c;

        }
    }

    if(operate==2)//substraction
    {
        cout<<"\t\t\t Enter your first number:";
        cin>>first;
        cout<<endl<<endl;
        cout<<"\t\t\t Enter your second number:";
        cin>>second;
        cout<<endl;

        total= (first-second);
    }


    if(operate==3)//multiplication
    {
        cout<<"\t\t\t Enter your first number:";
        cin>>first;
        cout<<endl<<endl;
        cout<<"\t\t\t Enter your second number:";
        cin>>second;
        cout<<endl;

        total= (first*second);
    }

    if(operate==4)//division
    {
        cout<<"\t\t\t Enter your first number:";
        cin>>first;
        cout<<endl<<endl;
        cout<<"\t\t\t Enter your second number:";
        cin>>second;
        cout<<endl;
        total=first/second;
    }

    return total;

}

void binary(int num) //for number 3
{
    ofstream outfile;
    outfile.open("conversion.txt",fstream::app);
    int rem;

    if (num<=1)
    {
        cout<<" "<<num;
        outfile<<num;
        return;
    }
    rem=num%2;
    binary(num/2);
    cout<<" "<< rem;
    outfile<<rem;

    outfile.close();


}

void findQuadratic1(double &x,double &y, double &z) //for number 7
{
    ofstream outfile;
    outfile.open("quadratic.txt",fstream::app);
    double f,i,j,x1,x2,x3;

    f = pow(y,2);
    i = f-(4*x*z);
    j = abs(i);
    x1 = sqrt(j)+(-y)/(2)*x;
    x2 = -y -(sqrt(j))/(2)*x;
    cout<<"\t\t\t The value of x is: "<<x1<<" , "<<x2;
    outfile<<x1<<x2;

    outfile.close();
}






# data[].attributes.body
1) MOHAMAD HAZIQ BIN HUSIN
2) MUHAMAD ZULKHAIRI BIN AZMAN
3) MOHAMAD FARHAN BIN JUAHIR

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<cmath>
#include<fstream>
#include<stdlib.h>
#include<iomanip>

using namespace std;

const double PI = 3.14159;

struct rectangle
{
    float length;
    float height;
    float width;
};

struct electrical
{
    float current;
    float voltage;
    float resistance;
    float capacitance;
    float charge;
};

void scalar (double, double, double);
void calcMatrices (int[][100]);
void conversion();
void trigonometric (float, double);
void calcElectrical (float, float, float, float, float);
void measureObject (float, float, float);
void quadratic (float &, float &);
void calculating();

int main()
{

    int choice, exit, sum[100][100];
    double a,b,c,answer;
    float area, perimeter, volume;
    float x,y;
    float angle;
    char hex[100];
    float power, voltage, current, charge, capacitance;
      cout << "\t\t\t\t\t\t\t\t\t\t\t\t\tYOUR CALCULATOR" << endl << endl;
    p:cout << " Choose the operation" << endl << endl;
      cout << "1. Operations of Scalar Value" << endl;
      cout << "2. Matrices" <<endl;
      cout << "3. Base Conversion" << endl;
      cout << "4. Trigonometric Operation" << endl;
      cout << "5. Electrical Calculation" << endl;
      cout << "6. Calculate Area, Volume, Perimeter" << endl;
      cout << "7. Quadratic Equations" << endl << endl;
      cout << "Choice: ";
      cin >> choice;

    system("cls");

    if(choice == 1)
        scalar(a, b, c);

    else if(choice == 2)
        calcMatrices(sum);

    else if(choice == 3)
        conversion();

    else if(choice == 4)
        trigonometric (angle, answer);

    else if(choice == 5)
        calcElectrical (power, voltage, current, charge, capacitance);

    else if(choice == 6)
        measureObject (area, perimeter, volume);

    else if(choice == 7)
        quadratic (x, y);

    else
    {
        system("cls");
        cout << "\a\n\t       NOT IN LIST !!";
        cout << "\a\n\tPLEASE ENTER NUMBER 1 UNTIL 7" << endl << endl;
        goto p;
    }

    d:cout << "\n  Choose:\t1. Continue\n\t\t2. Exit\n\n\t Choice: ";
    cin >> exit;

    if(exit == 1)
    {
        system("cls");
        goto p;
    }

    else if(exit ==2)
    {
       cout << "\n\n\tTHANK YOU !!" << endl;
        return 0;
    }

    else
    {
        system("cls");
        cout << "\a\n\t       NOT IN LIST !!";
        cout << "\a\n\tPLEASE ENTER NUMBER 1 UNTIL 7" << endl << endl;
        goto p;
    }

}

void scalar(double a, double b, double c)
{
    fstream dataFile;

    int exp,h,scalarMenu;
    char history;
    scalarMenu:cout << "\n Choose the given mathematical expressions:\n\n";
    cout << setw(10) << " 1.Addition"
         << setw(20) << "2.Subtraction"
         << setw(25) << "3.Multiplication"
         << setw(20) << "4.Division" << endl << endl;
    cout << "Choice :";
    cin >> exp;

    system("cls");

    switch(exp)
    {
        case 1:{
                    cout << "\n Enter any numbers to be calculated(a & b):\n";
                    cout << " a?: ";
                    cin >> a;
                    cout << " b?: ";
                    cin >> b;
                    cout << endl;
                    c=a+b;
                    cout << "\n " << a << "+" << b << "=" << c << endl;
                    break;
               }
        case 2:{
                    cout << "\n Enter any numbers to be calculated(a & b):\n";
                    cout << " a?: ";
                    cin >> a;
                    cout << " b?: ";
                    cin >> b;
                    cout << endl;
                    c=a-b;
                    cout << "\n " << a << "-" << b << "=" << c << endl;
                    break;
               }
        case 3:{
                    cout << "\n Enter any numbers to be calculated(a & b):\n";
                    cout << " a?: ";
                    cin >> a;
                    cout << " b?: ";
                    cin >> b;
                    cout << endl;
                    c=a*b;
                    cout << "\n " << a << "x" << b << "=" << c << endl;
                    break;
               }
        case 4:{
                    cout << "\n Enter any numbers to be calculated(a & b):\n";
                    cout << " a?: ";
                    cin >> a;
                    cout << " b?: ";
                    cin >> b;
                    cout << endl;
                    c=a/b;
                    cout << "\n " << a << "/" << b << "=" << c << endl;
                    break;
               }
        default:{
                    system("cls");
                    cout << "\n\t WRONG CHOICE!" << endl;
                    goto scalarMenu;
                }
    }
    dataFile.open("calculation.txt", ios::out|ios::app);
    dataFile << c << endl;
    h:cout << "\n Do you want to view history? (Press Y for Yes/N for No): ";
    cin >> history;

    system("cls");
    if(history == 'Y' || history == 'y')
    {
        dataFile.open("calculation.txt", ios::out|ios::app);
        dataFile >> c;
        cout << "\n " << c << endl;
    }
    else if (history == 'N' || history == 'n')
        cout << endl;//proceed to the next flow);
    else
    {
        system("cls");
            cout << "\a\n\t            WRONG INPUT!";
            cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO"<< endl << endl;
        goto h;
    }
    dataFile.close();
}

void calcMatrices(int sum[100][100])
{
    fstream dataMatrices; // To read and write data.

    int calc,row1,row2,column1,column2,c,d,e,first[100][100],second[100][100],third[100][100];
    char history2;

    system("cls");

    matricesMenu:cout << "\n Choose one of the calculations:\n\n" // Matrices menu
         << " 1. Addition of matrices\n"
         << " 2. Subtraction of matrices\n"
         << " 3. Multiplication of matrices\n\n" << endl;
    cout << "\tChoice :";
    cin >> calc;
    cout << endl;

    dataMatrices.open("matrices.txt", ios::out|ios::app); // Create and open file matrices.txt .
    switch(calc)
    {
        case 1:{
                    cout << "\n Enter the number of rows and columns of matrix:\n";
                    cout << " Row: ";
                    cin >> row1;
                    cout << " Column: ";
                    cin >> column1;

                    cout << "\n Enter the elements of first matrix:\n";
                    for(c=0;c<row1;c++)
                        for(d=0;d<column1;d++)
                        {
                            cout << " ";
                            cin >> first[c][d];
                        }

                    cout << "\n Enter the elements of second matrix:\n";
                    for(c=0;c<row1;c++)
                        for(d=0;d<column1;d++)
                        {
                            cout << " ";
                            cin >> second[c][d];
                        }
                    cout << "\n Sum of entered matrices:\n\n";
                    for(c=0;c<row1;c++)
                    {
                        for(d=0;d<column1;d++)
                        {
                            sum[c][d] = first[c][d] + second[c][d]; // Calculation
                            cout << " " << sum[c][d] << "\t";
                            dataMatrices << sum[c][d] << "\t"; // Write the data to file matrices.txt .
                        }
                        dataMatrices << "\n";
                        cout << endl;
                    }
                    cout << endl;
                    break;
                }

        case 2:{
                    cout << "\n Enter the number of rows and columns of matrix:\n";
                    cout << " Row: ";
                    cin >> row1;
                    cout << " Column: ";
                    cin >> column1;

                    cout << "\n Enter the elements of first matrix:\n";
                    for(c=0;c<row1;c++)
                        for(d=0;d<column1;d++)
                        {
                            cout << " ";
                            cin >> first[c][d];
                        }

                    cout << "\n Enter the elements of second matrix:\n";
                    for(c=0;c<row1;c++)
                        for(d=0;d<column1;d++)
                        {
                            cout << " ";
                            cin >> second[c][d];
                        }
                    cout << "\n Total of entered matrices:\n\n";
                    for(c=0;c<row1;c++)
                    {
                        for(d=0;d<column1;d++)
                        {
                            sum[c][d] = first[c][d] - second[c][d];
                            cout << " " << sum[c][d] << "\t";
                            dataMatrices << sum[c][d] << "\t";
                        }
                        cout << endl;
                    }
                    cout << endl;
                    break;
                }

        case 3:{
                    mat:cout << "\n---------------------------------------------------------" << endl;
                    cout << "\n Enter the number of rows and columns of first matrix:\n";
                    cout << " Row: ";
                    cin >> row1;
                    cout << " Column: ";
                    cin >> column1;

                    cout << "\n Enter the number of rows and columns of second matrix:\n";
                    cout << " Row: ";
                    cin >> row2;
                    cout << " Column: ";
                    cin >> column2;

                    if(column1==row2)
                    {
                        cout << "\n---------------------------------------------------------" << endl;
                        cout << "\n Enter the elements of first matrix:\n";
                        for(c=0;c<row1;c++)
                            for(d=0;d<column1;d++)
                            {
                                cout << " ";
                                cin >> first[c][d];
                            }

                        cout << "\n Enter the elements of second matrix:\n";
                        for(c=0;c<row2;c++)
                            for(d=0;d<column2;d++)
                            {
                                cout << " ";
                                cin >> second[c][d];
                            }

                        cout << endl;
                        cout << "\n Product of entered matrices:\n\n";
                        for (c=0;c<row1;c++)
                        {
                            for (d=0;d<column2;d++)
                            {
                                third[c][d] = 0;
                            }
                        }
                        for (c=0;c<row1;c++)
                        {
                            third[c][0] = 0;
                            for (d=0;d<column2;d++)
                            {
                                for (e=0;e<row2;e++)
                                {
                                    third[c][d] = third[c][d] + first[c][e] * second[e][d];
                                }
                            }
                        }

                        for (c=0;c<column1;c++)
                        {
                            for (d=0;d<column2;d++)
                            {
                                cout << " " << third[c][d] << "\t";
                                dataMatrices << third[c][d] << "\t";
                            }
                            cout << endl;
                            dataMatrices << endl;
                        }
                        dataMatrices << "----------------------------------------------------" << endl;
                        cout << endl;
                    }
                    else
                        goto mat;
                    break;
                }
        default:{
                    system("cls");
                    cout << "\a\n\t  WRONG CHOICE!" << endl;
                    goto matricesMenu; // Return to matricesMenu.
                }
    }
    h2:cout << "\n Do you want to view history? (Press Y for Yes/N for No): ";
    cin >> history2;

    system("cls");
    if(history2 == 'Y' || history2 == 'y')
    {
        cout << endl;
        for(c=0;c<column1;c++)
        {
            for(d=0;d<column2;d++)
            {
                dataMatrices >> third[c][d]; // Read the data from file matrices.txt .
                cout << " " << third[c][d] << "\t";
            }
            cout << endl;
        }
        cout << endl;
    }
    else if (history2 == 'N' || history2 == 'n')
        cout << endl; //proceed to the next flow
    else
    {
        system("cls");
        cout << "\a\n\t     WRONG INPUT!";
        cout << "\n\n -----------------------------------\n\n";
        goto h2; // Return to h2.
    }
    dataMatrices.close(); // Close the file.
}

void conversion()
{
    fstream baseConversion;

    int number,base,baseMenu,n,remainder,remain[500],times = 0,h3a,h3b;
    char history3a,history3b;
    baseMenu:cout << "\n Choose any desired conversion:"
                  << "\n 1. Decimal to Binary"
                  << "\n 2. Decimal to Hexadecimal"
                  << "\n\n Choice?: ";
    cin >> base;
    cout << endl;
    system("cls");
    switch (base)
    {
        case 1:
        {
            n:cout << "\n\n Please enter any positive integer: ";
            cin >> number;
            if (number<0)
            {
               system("cls");
               cout << "\a\n\n  WRONG INTEGER!";
               goto n;
            }
            else
            {
                cout << endl;
                while(number>0)
                {
                    remainder = number%2;
                    remain[times]=remainder;
                    number = number/2;
                    times++;
                };
                cout << "\n After conversion: ";
                baseConversion.open("base.txt",ios::out|ios::app);

                baseConversion << "Binary: ";
                for(int i=times-1;i>=0;i--)
                {
                    cout << remain[i];
                    baseConversion << remain[i];
                }
                baseConversion << endl;
                h3a:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
                cin >> history3a;

                system("cls");
                if(history3a=='Y' || history3a=='y')
                {
                    cout << "\n Binary: ";
                    for(int i=times-1;i>=0;i--)
                    {
                        baseConversion >> remain[i];
                        cout << remain[i];
                    }
                    cout << "\n" << endl;
                }
                else if(history3a=='N' || history3a=='n')
                cout << endl;
                else
                {

                system("cls");
            cout << "\a\n\t             WRONG INPUT!";
            cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;

                goto h3a;

                }
                baseConversion.close();
            }
            break;
        }
        case 2:
        {
            long int number2,remainder,quotient,n2;
            int i=1,j,r;
            char hexadecimalNumber[100];

            n2:cout<<"\n Enter any positif integer: ";
            cin>>number2;
            if(number2<0)
            {
               system("cls");
               cout << "\a\n\t  WRONG INTEGER!\n";
               goto n2;
            }

            quotient = number2;

            while(quotient!=0)
            {
                r = quotient % 16;

                //To convert integer into character
                if(r < 10)
                    r = r + 48;
                else
                    r = r + 55;

                hexadecimalNumber[i++] = r;
                quotient = quotient / 16;
            }
            baseConversion.open("base.txt",ios::out|ios::app);
            cout<<"\n Equivalent hexadecimal number of "<< number2 <<" is : ";

            baseConversion << "Hexa :";
            for(j = i-1 ;j> 0;j--)
            {
                cout << hexadecimalNumber[j];
                baseConversion << hexadecimalNumber[j];
            }
            baseConversion << endl;
            h3b:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
            cin >> history3b;

            system("cls");
            if(history3b=='Y' || history3b=='y')
            {
                cout << "\n Hexa: ";
                for(j = i-1 ;j> 0;j--)
                {
                    baseConversion >> hexadecimalNumber[j];
                    cout << hexadecimalNumber[j];
                }
                cout << endl;
            }
            else if(history3b=='N' || history3b=='n')
                cout << endl;
            else
            {

            system("cls");
            cout << "\a\n\t             WRONG INPUT!";
            cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;

            goto h3b;

            }
            baseConversion.close();
            cout<<endl;
            break;
        }
        default:
        {
            system("cls");
            cout << "\a\n\t     Invalid choice!"
                 << "\n\n  ------------------------------------- \n\n";
            goto baseMenu;
        }

    }
}

void trigonometric(float angle, double answer)
{
    fstream trigo; // To read and write the data.

    int operation,h6;
    float ang;
    char history6;

    p:cout << "\n Choose your Trigonometric Operation" <<endl; // Trigonometric menu.
    cout << "1. sin\n2. cos\n3. tan\n4. cosecant\n5. secant\n6. cotangent" << endl;
    cout << "\n\tChoice :";
    cin >> operation;
    cout << endl;

    trigo.open("Trigonometric.txt",ios::out|ios::app); // Create and open the file "Trigonometric.txt" .

    if(operation == 1)
    {
        cout << "\n Enter your angle: ";
        cin >> angle;
        ang=(angle*PI)/180;
        answer = sin(ang);
        cout << "\n sin " << angle << " = " << answer << " deg" << endl;
        trigo <<"sin " << angle << " = " << answer << " deg" << endl; // Write the data to file Trigonometric.txt .
    }
    else if(operation == 2)
    {
        cout << "\n Enter your angle: ";
        cin >> angle;
        ang=(angle*PI)/180;
        answer = cos(ang);
        cout << "\n cos " << angle << " = " << answer << " deg" << endl;
        trigo << "cos " << angle << " = " << answer << " deg" << endl;
    }
    else if(operation == 3)
    {
        cout << "\n Enter your angle: ";
        cin >> angle;
        ang=(angle*PI)/180;
        answer = tan(ang);
        cout << "\n tan " << angle << " = " << answer << " deg" << endl;
        trigo << "tan " << angle << " = " << answer << " deg" << endl;
    }
    else if(operation == 4)
    {
        cout << "\n Enter your angle: ";
        cin >> angle;
        ang=(angle*PI)/180;
        answer = 1/(sin(ang));
        cout << "\n cosec " << angle << " = " << answer << " deg" << endl;
        trigo << "cosec " << angle << " = " << answer << " deg" << endl;
    }
    else if(operation == 5)
    {
        cout << "\n Enter your angle: ";
        cin >> angle;
        ang=(angle*PI)/180;
        answer = 1/(cos(ang));
        cout << "\n sec " << angle << " = " << answer << " deg" << endl;
        trigo << "sec " << angle << " = " << answer << " deg" << endl;
    }
    else if(operation == 6)
    {
        cout << "\n Enter your angle: ";
        cin >> angle;
        ang=(angle*PI)/180;
        answer = 1/(tan(ang));
        cout << "\n cot " << angle << " = " << answer << " deg" << endl;
        trigo << "cot " << angle << " = " << answer << " deg" << endl;
    }
    else
    {
        system("cls");
        cout << "\a\n\t     Invalid choice!"
             << "\n\n  ------------------------------------- \n\n";
        goto p; // Return to p.
    }

    h6:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
    cin >> history6;

    system("cls");
    if(history6 == 'Y' || history6 == 'y')
    {
        trigo >> answer; // Read the data from file Trigonometric.txt .
        cout << "\n " << answer;
        cout << "\n" << endl;
    }
    else if(history6 == 'N' || history6 == 'n')
        cout << endl; //proceed to the next flow
    else
    {
        system("cls");
        cout << "\a\n\t     WRONG INPUT!";
        cout << "\n\n -----------------------------------\n\n";
        goto h6; // Return to h6.
    }
    trigo.close(); // Close the file.
}

void calcElectrical(float power, float voltage, float current, float charge, float capacitance)
{
    fstream calcElectric;

    int choice,h7a,h7b,h7c,h7d,h7e;
    char history7a,history7b,history7c,history7d,history7e;
    electrical e1;

    p:cout << "\n 1. Current\n 2. Voltage\n 3. Power\n 4. Charge\n 5. Capacitance" << endl;
    cout << "\n\tChoice :";
    cin >> choice;

    system("cls");

    calcElectric.open("CalcElectrical.txt",ios::out|ios::app);

    if( choice == 1)
    {
        cout << " Please enter the value of voltage :";
        cin >> e1.voltage;

        cout << " Please enter the value of resistance :";
        cin >> e1.resistance;
        cout << endl;

        e1.current = e1.voltage / e1.resistance;
        e1.voltage = e1.current * e1.resistance;
        power = e1.voltage * e1.current;

        cout << " The value of current is " << setprecision(3)<< e1.current<< " A" << endl;
        cout << " The value of power is "<< power << " W" << endl;
        cout << " The value of voltage is " <<e1.voltage << " V" << endl;

        calcElectric << "\nThe value of current is " << setprecision(3)<< e1.current<< " A" << endl;
        calcElectric << "The value of power is "<< power << " W" << endl;
        calcElectric << "The value of voltage is " <<e1.voltage << " V" << endl;

        h7a:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history7a;

        system("cls");
        if(history7a == 'Y' || history7a == 'y')
        {
            calcElectric >> e1.current;
            calcElectric >> power;
            calcElectric >> e1.voltage;

            cout << " The value of current is " << setprecision(3)<< e1.current<< " A" << endl;
            cout << " The value of power is "<< power << " W" << endl;
            cout << " The value of voltage is " <<e1.voltage << " V" << endl;
        }
        else if(history7a == 'N' || history7a == 'n')
            cout << endl; //proceed to the next flow
        else
        {
        system("cls");
        cout << "\a\n\t            WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;

        goto h7a;
        }
    }
    else if(choice == 2)
    {
        cout << " Please enter the value of current :";
        cin >> e1.current;

        cout << " Please enter the value of resistance :";
        cin >> e1.resistance;
        cout << endl;

        e1.voltage = e1.current * e1.resistance;
        e1.current = e1.voltage / e1.resistance;
        power = e1.voltage * e1.current;

        cout << " The value of voltage is " <<e1.voltage << " V" << endl;
        cout << " The value of current is " << setprecision(3) << e1.current<< " A" << endl;
        cout << " The value of power is "<< power << " W" << endl;

        calcElectric << "\n The value of voltage is " <<e1.voltage << " V" << endl;
        calcElectric << " The value of current is " << setprecision(3) << e1.current<< " A" << endl;
        calcElectric << " The value of power is "<< power << " W" << endl;

        h7b:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history7b;

        system("cls");
        if(history7b == 'Y' || history7b == 'y')
        {
            calcElectric >> e1.voltage;
            calcElectric >> e1.current;
            calcElectric >> power;

            cout << "The value of voltage is " <<e1.voltage << " V" << endl;
            cout << "The value of current is " << setprecision(3) << e1.current<< " A" << endl;
            cout << "The value of power is "<< power << " W" << endl;
        }
        else if(history7b == 'N' || history7b == 'n')
            cout << endl; //proceed to the next flow
        else
        {
        system("cls");
        cout << "\a\n\t             WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;

        goto h7b;
        }

    }
    else if(choice == 3)
    {
        cout << " Please enter the value of voltage :";
        cin >> e1.voltage;

        cout << " Please enter the value of current :";
        cin >> e1.current;
        cout << endl;

        power = e1.voltage * e1.current;

        cout << " The value of power is "<< power << " W" << endl;
        cout << " The value of voltage is " << e1.voltage << " V" << endl;
        cout << " The value of current is " << e1.current << " A" << endl;

        calcElectric << "\n The value of power is "<< power << " W" << endl;
        calcElectric << " The value of voltage is " << e1.voltage << " V" << endl;
        calcElectric << " The value of current is " << e1.current << " A" << endl;


        h7c:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history7c;

        system("cls");
        if(history7c == 'Y' || history7c == 'y')
        {
            calcElectric >> power;
            calcElectric >> e1.voltage;
            calcElectric >> e1.current;

            cout << " The value of power is "<< power << " W" << endl;
            cout << " The value of voltage is " << e1.voltage << " V" << endl;
            cout << " The value of current is " << e1.current << " A" << endl;
        }
        else if(history7c == 'N' || history7c == 'n')
            cout << endl; //proceed to the next flow
        else
        {
        system("cls");
        cout << "\a\n\t              WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;;

        goto h7c;
        }

    }
    else if(choice == 4)
    {
        cout << " Please enter the value of capacitance :";
        cin >> e1.capacitance;

        cout << " Please enter the value of voltage :";
        cin >> e1.voltage;
        cout << endl;

        e1.charge = e1.capacitance * e1.voltage;

        cout << " The value of charge is "<< e1.charge << " Q" << endl;

        calcElectric << "\nThe value of charge is "<< e1.charge << " Q" << endl;

        h7d:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history7d;

        system("cls");
        if(history7d == 'Y' || history7d == 'y')
        {
            calcElectric >> e1.charge;
            cout << " The value of charge is "<< e1.charge << " Q" << endl;
        }
        else if(history7d == 'N' || history7d == 'n')
            cout << endl; //proceed to the next flow
        else
        {

        system("cls");
        cout << "\a\n\t                WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;
        goto h7d;

        }

    }
    else if(choice == 5)
    {
        cout << " Please enter the value of charge :";
        cin >> e1.charge;

        cout << " Please enter the value of voltage :";
        cin >> e1.voltage;
        cout << endl;

        e1.capacitance = e1.charge / e1.voltage;

        cout << " The value of capacitance is "<< setprecision(3) << e1.capacitance<< " C" << endl;

        calcElectric << "\nThe value of capacitance is "<< setprecision(3) << e1.capacitance<< " C" << endl;

        h7e:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history7e;

        system("cls");
        if(history7e == 'Y' || history7e == 'y')
        {
            calcElectric >> e1.capacitance;
            cout << " The value of capacitance is "<< setprecision(3) << e1.capacitance<< " C" << endl;
        }
        else if(history7e == 'N' || history7e == 'n')
            cout << endl; //proceed to the next flow
        else
        {
        system("cls");
        cout << "\a\n\t             WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;
        goto h7e;

        }
    }
    else
    {
        cout << "\a\n\t  WRONG CHOICE!" << endl;
        goto p;
    }
    calcElectric.close();
}

void measureObject (float area, float perimeter, float volume)
{
    fstream object;

    rectangle box;
    int type,p,h4;
    float radius;
    char history4;

    p:cout << "\n Select the object type that you want to measure: " << endl;
    cout << " 1. Rectangles\n 2. Circles" << endl;
    cout << "\n\tChoice: ";
    cin >> type;

    system("cls");

    if( type == 1)
    {
        cout << "\n Please insert the length: ";
        cin >> box.length;

        cout << " Please insert the height: ";
        cin >> box.height;

        cout << " Please insert the width: ";
        cin >> box.width;

        area = box.length * box.height;
        volume = box.length * box.height * box.width;
        perimeter = (box.length*2)+(box.height*2);

        cout << endl;
        cout << "   The perimeter is " << perimeter << endl;
        cout << "   The area is " << area << endl;
        cout << "   The volume is " << volume << endl;
    }
    else if (type == 2)
    {
        cout << "\n Please insert the radius: ";
        cin >> radius;

        area = (pow(radius,2)) * 2.142;
        perimeter = 2 * 2.142 * radius;
        volume = 2.142 * (pow(radius,3)) * 4/3;

        cout << endl;
        cout << "   The perimeter is "<< perimeter << endl;
        cout << "   The area is " << area << endl;
        cout << "   The volume is " << volume << endl;
    }
    else
    {
        cout <<"\a\n\t  WRONG INPUT!" << endl;
        goto p;
    }

    object.open("MeasureObject.txt",ios::out|ios::app);
    object << " Perimeter : " << perimeter <<endl;
    object << " Area : " << area << endl;
    object << " Volume : " << volume << endl;
    object << endl;

    h4:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
    cin >> history4;

    system("cls");
    if(history4 == 'Y' || history4 == 'y')
    {
        object >> perimeter;
        object >> area;
        object >> volume;

        cout << "\n Perimeter: " << perimeter << endl;
        cout << " Area: " << area << endl;
        cout << " Volume: " << volume << endl;
        cout << endl;
    }
    else if(history4 == 'N' || history4 == 'n')
        cout << endl; //proceed to the next flow
    else
    {
        system("cls");
        cout << "\a\n\t              WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;
        goto h4;
    }
    object.close();
}

void quadratic(float &x, float &y)
{
    fstream quad;

    int a, b, c,h5a,h5b;
    float equation;
    char history5a,history5b;

    cout << "\n Please enter the value of a :";
    cin >> a;

    cout << " Please enter the value of b :";
    cin >> b;

    cout << " Please enter the value of c :";
    cin >> c;

    cout << endl;

    equation = pow(b,2) -(4*a*c);
    quad.open("Quadratic.txt",ios::out|ios::app);

    cout << "\n Your quadratic function is " << a <<"x^2 + " << b << "x + " << c << endl << endl;

    if(equation > 0)
    {
        cout << "   There are two real roots." << endl;

        x = (-b + pow((b*b -(4*a*c)),0.5))/ (2*a);
        y = (-b - pow((b*b -(4*a*c)),0.5))/ (2*a);

        cout << "   The roots are " << x <<" and " << y << "." << endl;

        quad << "\n   X :"<<x << "\tY :" << y;

        h5a:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history5a;

        system("cls");
        if(history5a == 'Y'||history5a == 'y')
        {
            quad >> x;
            quad >> y;
            cout << "\n X: " << x << "\tY: " << y;
            cout << "\n" << endl;
        }
        else if(history5a == 'N'||history5a == 'n')
            cout << endl; //proceed to the next flow
        else
        {
        system("cls");
        cout << "\a\n\t              WRONG INPUT!";
        cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO" << endl << endl;
        goto h5a;
        }
        quad.close();

    }

    else if (equation == 0)
    {
        cout << "   There is one real root." << endl;

        x = (-b + pow((b*b -(4*a*c)),0.5))/ (2*a);

        cout << "   The root is " << x << "." << endl;

        quad << "\n   X :" << x;

        h5b:cout << "\n Do you want to view history? (Y for Yes,N for No): ";
        cin >> history5b;
        system("cls");
        if(history5b == 'Y' || history5b == 'y')
        {
            quad >> x;
            cout << "\n   X: " << x;
            cout << "\n" << endl;
        }
        else if(history5b == 'N' || history5b == 'n')
            cout << endl; //proceed to the next flow
        else
        {
            system("cls");
            cout << "\a\n\t              WRONG INPUT!";
            cout << "\a\n\t PLEASE ENTER 'Y' FOR YES AND 'N' FOR NO"
             << endl << endl;
            goto h5b;
        }
        quad.close();
    }

    else if (equation < 0)
    {
        cout << "   There is no real root." << endl;
        cout << endl;
        quad.close();
    }
}

# data[].attributes.body
MOHAMAD ASHRAF B MD GHARIF
MUHAMMAD AMIRUL BIN ROSLI
MUHAMMAD SYUKRI HAKIM BIN NOR MUHAMAD

# data[].attributes.body
Mohamad Ashraf B Md Gharif
Muhammad Amirul Bin Rosli
Muhammad Syukri Hakim Bin Nor Muhamad

# data[].attributes.attachment_link.readable_text
//RIMBA BARA MINI PROJECT
//EE2423B
//ECE431
#include<iostream>//i/o stream library
#include<cmath>//to use math operation
#include<iomanip>//parametric manipulator
#include<stdlib.h>//general purpose function
#include<fstream>//to write file

using namespace std;//using namespace std

struct rectangle//struct for triangle
{
   float length,
         width,
         height,
         area,
         perimeter,
         volume;
};

struct circle//struct for circle
{
    float radius,
          area,
          perimeter,
          volume;
};

const float PI = 3.142;//const PI

void getValue(float &, float &);//get value for no1
void computeCalculation(float &, float &);//calculate sum,sub,multiply,division
void getMatrix();
void convBin(long &);//convert from dec to bin
void convHex(long &);//convert dec to hex
void convBinToHex(long int &);//bin to hex
void convBinToDec(int &);//bin to dec
void convHexToDec(char &);//hex to dec
void getAngle(double &);//get angle for trigo
void showCos(double);//show the value of cos
void showSin(double);//show the value of sine
void showTan(double);//show the value of tangent
void showCosec(double);//show the value of cosec
void showSec(double);//show the value of secant
void showCot(double);//show the value of cotangent
void calcCapacitance(float &, float &);//calculate capacitance
void calcElectricCharge(float &, float &);//calculate ec
void calcVoltage(float &,float &);//calculate voltage
void calcPower(float &,float &);//calculate power
void calcCurrent(float &,float &);//calculate current
void getDimension(rectangle &,circle &);//get dimension of rectangle and circle
void showDimension(rectangle ,circle );//show the dimension
void eqtroot(float ,float ,float );//root

int main()
{
    int option;//option for switch case

    while(option != -1)//sentinel,looping until -1 is entered
    {

        cout<<"This program will calculate: "
            <<"\n\n1. Summation,subtraction,multiplication and division of scalar values"
            <<"\n2. Summation, subtraction and multiplication of matrices "
            <<"\n3. Conversion between Binary values, Hexadecimal values and Decimal values"//conert base
            <<"\n4. Trigonometric operations such as finding cosine, sine, tangent, cotangent,"
            <<"\n   cosecant and secant"//calculate trigonometric function
            <<"\n5. Compute Electrical Charge, Capacitance, Current, Voltage and Power"//calculate ec,capacitance,current,volt,power
            <<"\n6. Compute Perimeter/Circumference, Area and Volume of circles and rectangles"//calculate perimeter,area and volume of circle and rect
            <<"\n7. Solve roots of quadratic equation "
            <<"\n\nEnter -1 to quit this program"
            <<endl;

        cout<<"\nPlease enter your option: "<<endl;
        cin>>option;

        system("cls");//system clear

        switch(option)
        {
            case 1: float d,e;
                    getValue(d,e);
                    computeCalculation(d,e);

                    break;

            case 2: getMatrix();
                    break;

            case 3: int ch;
                    cout<<"1. Decimal to Binary number"
                        <<"\n2. Decimal to Hexadecimal number"
                        <<"\n3. Binary to Hexadecimal number"
                        <<"\n4. Binary to Decimal number"
                        <<"\n5. Hexadecimal to Decimal number"
                        <<"\n6. Hexadecimal to Binary number"<<endl;
                    cout<<"\nPlease enter your option: "<<endl;
                    cin>>ch;

                    switch(ch)
                    {
                    case 1: long decimal;
                            cout<<"Please enter the decimal number"<<endl;//user input decimal number
                            cin>>decimal;//read decimal input

                            convBin(decimal);

                            break;//break out from switch

                    case 2: long dec;
                            cout << "Please enter Decimal number: ";//user input decimal number
                            cin >> dec;//read decimal number
                            convHex(dec);

                            break;

                    case 3: long int bin;
                            cout << "Please enter Binary number: ";//user input binary number
                            cin >> bin;//read binary number
                            convBinToHex(bin);

                            break;

                    case 4: int binary;
                            cout << "Please enter Binary number: ";
                            cin >> binary;
                            convBinToDec(binary);

                            break;

                    case 5: char hexa;
                            cout<<"Please enter the Hexadecimal number:";
                            cin>>hexa;
                            convHexToDec(hexa);

                            break;

                    case 6: char Hex[1000];
                            ofstream HTB;
                            HTB.open("htb.txt",fstream::app);
                            long int i = 0;
                            cout << "Please enter Hexadecimal number: ";
                            cin >> Hex;
                            while(Hex[i])
                            {
                                switch(Hex[i])
                                    {
                                        case '0': cout << "0000";//display 0000
                                                  HTB << "0000" << endl;
                                        break;
                                        case '1': cout << "0001";//display 0001
                                                  HTB << "0001" << endl;
                                        break;
                                        case '2': cout << "0010";//display 0010
                                                  HTB << "0010" << endl;
                                        break;
                                        case '3': cout << "0011";//display 0011
                                                  HTB << "0011" << endl;
                                        break;
                                        case '4': cout << "0100";//display 0100
                                                  HTB << "0100" << endl;
                                        break;
                                        case '5': cout << "0101";//display 0101
                                                  HTB << "0101" << endl;
                                        break;
                                        case '6': cout << "0110";//display 0110
                                                  HTB << "0110" << endl;
                                        break;
                                        case '7': cout << "0111";//display 0111
                                                  HTB << "0111" << endl;
                                        break;
                                        case '8': cout <<"1000";//display 1000
                                                  HTB << "1000" << endl;
                                        break;
                                        case '9': cout << "1001";//display 1001
                                                  HTB << "1001"<< endl;
                                        break;
                                        case 'A': cout << "1010";//display 1010
                                                  HTB << "1010" << endl;
                                        break;
                                        case 'B': cout << "1011";//display 1011
                                                  HTB << "1011" << endl;
                                        break;
                                        case 'C': cout << "1100";//display 1100
                                                  HTB << "1100" << endl;
                                        break;
                                        case 'D': cout << "1101";//display 1101
                                                  HTB << "1101" << endl;
                                        break;
                                        case 'E': cout << "1110";//display 1110
                                                  HTB << "1110" << endl;
                                        break;
                                        case 'F': cout << "1111";//display 1111
                                                  HTB << "1111" << endl;
                                        break;
                                        default: cout << "Invalid digit "<<Hex[i]<<endl;
                                                  HTB << "Invalid digit " << Hex[i] << endl;
                                    }

                                i++;
                                HTB.close();
                            }
                            break;


                    }

                    break;

            case 4: int value;
                    double radian;

                    cout<<"1. Cosine"
                        <<"\n2. Sine"
                        <<"\n3. Tangent"
                        <<"\n4. Cosecant"
                        <<"\n5. Secant"
                        <<"\n6. Cotangent"<<endl;

                    cout<<"\nPlease enter your option: "<<endl;
                    cin>>value;

                    switch(value)
                    {
                    case 1: getAngle(radian);
                            showCos(radian);

                            break;

                    case 2: getAngle(radian);
                            showSin(radian);

                            break;

                    case 3: getAngle(radian);
                            showTan(radian);

                            break;

                    case 4: getAngle(radian);
                            showCosec(radian);

                            break;

                    case 5: getAngle(radian);
                            showSec(radian);

                            break;

                    case 6: getAngle(radian);
                            showCot(radian);

                            break;


                    }
                    break;


            case 5: float Q,V,voltage,current,resistance,time;
                    int answer;
                    cout<<"1. Electrical Charge"
                        <<"\n2. Voltage"
                        <<"\n3. Capacitance"
                        <<"\n4. Power"
                        <<"\n5. Current"<<endl;

                    cout<<"\nPlease enter your option: "<<endl;
                    cin>>answer;



                    switch(answer)
                    {
                    case 1: cout<<"Please enter the value of current: "<<endl;//user input current value
                            cin>>current;//read current value

                            cout<<"Please enter the value of time(s): "<<endl;//user input time
                            cin>>time;//read time value

                            calcElectricCharge(current,time);
                            break;

                    case 2: cout<<"Please enter the value of current: "<<endl;//user input current value
                            cin>>current;//read current value

                            cout<<"Please enter the value of resistance: "<<endl;//user input resistance value
                            cin>>resistance;//read resistance value

                            calcVoltage(current,resistance);
                            break;

                    case 3: cout<<"Please enter the value of electric charge: "<<endl;//user input electric charge value
                            cin>>Q;//read electric charge value

                            cout<<"Please enter the value of voltage: "<<endl;//user input voltage value
                            cin>>V;//read voltage value

                            calcCapacitance(Q,V);
                            break;

                    case 4: cout<<"Please enter the value of current: "<<endl;//user input current value
                            cin>>current;//read current value

                            cout<<"Please enter the value of resistance: "<<endl;//user input resistance value
                            cin>>resistance;//read resistance value

                            calcPower(current,resistance);
                            break;

                    case 5: cout<<"Please enter the value of voltage: "<<endl;//user input voltage value
                            cin>>voltage;//read voltage value

                            cout<<"Please enter the value of resistance: "<<endl;//user input resistance value
                            cin>>resistance;//read resistance value

                            calcCurrent(voltage,resistance);
                            break;

                    }

                    break;


            case 6: rectangle box;
                    circle circle1;

                    getDimension(box, circle1);
                    showDimension(box, circle1);
                    break;

            case 7: float a,b,c ;//variable type float a,b,c
                    cout<< "Enter the coefficient a,b,c : " <<endl ;
                    cin >> a>>b>>c;

                    cout << "Your quadratic function is:" << a << "x^2+"<<b<< "x+"<< c<< endl;
                    eqtroot (a,b,c);

                    break;
                    }

    cout<<"\n"<<endl;

    }


    return 0;
}

void getValue(float &d, float &e)//get input from user
{
    cout<<"Please enter two value: "<<endl;
    cin>>d>>e;
}

void computeCalculation(float &d, float &e)//sum,sub,mul,div
{
    ofstream first;
    first.open("first.txt",fstream::app);
    float add,sub,mul,div;
    add = d+e;
    sub = d-e;
    mul = d*e;
    div = d/e;

    cout<<"The summation of the value is: "<<add<<endl;
    cout<<"The subtraction of the value is: "<<sub<<endl;
    cout<<"The multiplication of the value is: "<<mul<<endl;
    cout<<"The division of the value is: "<<div<<endl;

    first<<"Summation:"<<add<<endl;
    first<<"Subtraction:"<<sub<<endl;
    first<<"Multiplication:"<<mul<<endl;
    first<<"Division:"<<div<<endl;

    first.close();
}

void getMatrix()//get the first and second matrix
{
    int c, d, first[2][2], second[2][2], sum[2][2];
    ofstream matrix;
    matrix.open("matrix.txt",fstream::app);//open matix file

    cout<<"Enter the elements of first matrix"<<endl;//ask user to put the first matrix

    for (c = 0; c < 2; c++)
       for (d = 0; d < 2; d++)
           cin>>first[c][d];//read first matrix

    cout<<"Enter the elements of second matrix"<<endl;//ask user to put the second matrix

    for (c = 0; c < 2; c++)
       for (d = 0 ; d < 2; d++)
           cin>>second[c][d];//read second matrix

    cout<<"Sum of entered matrices: "<<endl;
    matrix<<"Sum of entered matrices: "<<endl;

    for (c = 0; c < 2; c++)
    {
       for (d = 0 ; d < 2; d++)
        {
           sum[c][d] = first[c][d] + second[c][d];
           cout<<sum[c][d]<<"  ";//sum matrix
           matrix<<sum[c][d]<<"  ";
        }
        cout<<endl;
        matrix<<endl;
    }

    cout<<"Subtract of entered matrices: "<<endl;
    matrix<<"Subtract of entered matrices: "<<endl;

    for (c = 0; c < 2; c++)
    {
        for (d = 0 ; d < 2; d++)
       {
            sum[c][d] = first[c][d] - second[c][d];
            cout<<sum[c][d]<<"  ";//sub matrix
            matrix<<sum[c][d]<<"  ";
       }
       cout<<endl;
       matrix<<endl;
    }

    cout<<"Multiply of entered matrices: "<<endl;
    matrix<<"Multiply of entered matrices: "<<endl;

    for (c = 0; c < 2; c++)
    {
        for (d = 0 ; d < 2; d++)
        {
             sum[c][d] = first[c][d] * second[c][d];
             cout<<sum[c][d]<<"  ";//mul matrix
             matrix<<sum[c][d]<<"  ";
        }
        cout<<endl;
        matrix<<endl;
    }

     matrix.close();//close matrix file
}

void convBin(long &decimal)
{
    int rest;
    fstream BIN;
    BIN.open("bin.txt",fstream::app);
    long binary = 0,i = 1;

    while(decimal != 0)
    {
        rest = decimal %2;
        decimal = decimal / 2;
        binary = binary + (rest * i);
        i = i * 10;
    }

    cout<<"The binary number is:"<<binary;
    BIN<<"The binary number is:"<<binary;

    BIN.close();
}

void convHex(long &dec)
{
    int rem;
    ofstream HEX;
    HEX.open("hex.txt",fstream::app);
    while (dec > 0)
    {
       rem = dec % 16;
       if (rem > 9)
        {
            switch (rem)
            {
                case 10: cout << "The Hexadecimal number is A";
                         HEX << "The Hexadecimal number is A"<<endl;
                break;
                case 11: cout << "The Hexadecimal number is B";
                         HEX << "The Hexadecimal number is B"<<endl;
                break;
                case 12: cout << "The Hexadecimal number is C";
                         HEX << "The Hexadecimal number is C"<<endl;
                break;
                case 13: cout << "The Hexadecimal number is D";
                         HEX << "The Hexadecimal number is D"<<endl;
                break;
                case 14: cout << "The Hexadecimal number is E";
                         HEX << "The Hexadecimal number is E"<<endl;
                break;
                case 15: cout << "The Hexadecimal number is F";
                         HEX << "The Hexadecimal number is F"<<endl;
                break;
            }
        }

        else
        {
           cout <<"The Hexadecimal number is "<<rem;
           HEX <<"The Hexadecimal number is "<<rem<<endl;
        }

        dec = dec / 16;
    }

    HEX.close();
}

void convBinToHex(long int &bin)
{
    long int i = 1,remain,hex = 0;
    ofstream BTH;
    BTH.open("bth.txt",fstream::app);
    if(bin>1001)
    {

             switch (bin)
              {
                 case 1010: cout << "The Hexadecimal number is A"<<endl;
                            BTH << "The Hexadecimal number is A"<<endl;
                 break;
                 case 1011: cout << "The Hexadecimal number is B";
                            BTH << "The Hexadecimal number is B"<<endl;
                 break;
                 case 1100: cout << "The Hexadecimal number is C";
                            BTH << "The Hexadecimal number is C"<<endl;
                 break;
                 case 1101: cout << "The Hexadecimal number is D";
                            BTH << "The Hexadecimal number is D"<<endl;
                 break;
                 case 1110: cout << "The Hexadecimal number is E";
                            BTH << "The Hexadecimal number is E"<<endl;
                 break;
                 case 1111: cout << "The Hexadecimal number is F";
                            BTH << "The Hexadecimal number is F"<<endl;
                 break;
                }
    }

    else
    {
        while(bin != 0)
        {
            remain = bin % 10;
            hex = hex + remain * i;
            i = i * 2;
            bin = bin/10;

        }

        cout<<"The Hexadecimal number is "<<hex;
        BTH<<"The Hexadecimal number is "<<hex<<endl;
    }
    BTH.close();
}

void convBinToDec(int &binary)
{
    int decimal = 0,base = 1, last;
    ofstream BTD;
    BTD.open("btd.txt",fstream::app);
    while(binary > 0)
    {
        last = binary % 10;
        decimal = decimal + last * base;
        binary = binary / 10;
        base = base * 2;
    }

    cout<<"The Decimal number is "<<decimal<<endl;
    BTD<<"The Decimal number is "<<decimal<<endl;

    BTD.close();

}

void convHexToDec(char &hexa)
{
    ofstream HTD;
    HTD.open("htd.txt",fstream::app);
    switch(hexa)
        {
        case '1': cout<<"The decimal number is 1";
                  HTD<<"The decimal number is 1"<<endl;
                  break;

        case '2': cout<<"The decimal number is 2";
                  HTD<<"The decimal number is 2"<<endl;
                  break;

        case '3': cout<<"The decimal number is 3";
                  HTD<<"The decimal number is 3"<<endl;
                  break;

        case '4': cout<<"The decimal number is 4";
                  HTD<<"The decimal number is 4"<<endl;
                  break;

        case '5': cout<<"The decimal number is 5";
                  HTD<<"The decimal number is 5"<<endl;
                  break;

        case '6': cout<<"The decimal number is 6";
                  HTD<<"The decimal number is 6"<<endl;
                  break;

        case '7': cout<<"The decimal number is 7";
                  HTD<<"The decimal number is 7"<<endl;
                  break;

        case '8': cout<<"The decimal number is 8";
                  HTD<<"The decimal number is 8"<<endl;
                  break;

        case '9': cout<<"The decimal number is 9";
                  HTD<<"The decimal number is 9"<<endl;
                  break;

        case 'A': cout<<"The decimal number is 10";
                  HTD<<"The decimal number is 10"<<endl;
                  break;

        case 'B': cout<<"The decimal number is 11";
                  HTD<<"The decimal number is 11"<<endl;
                  break;

        case 'C': cout<<"The decimal number is 12";
                  HTD<<"The decimal number is 12"<<endl;
                  break;

        case 'D': cout<<"The decimal number is 13";
                  HTD<<"The decimal number is 13"<<endl;
                  break;

        case 'E': cout<<"The decimal number is 14";
                  HTD<<"The decimal number is 14"<<endl;
                  break;

        case 'F': cout<<"The decimal number is 15";
                  HTD<<"The decimal number is 15"<<endl;
                  break;
        }
}

void getAngle(double &radian)//get the angle for trigo
{
    double degree;
    cout << "Please enter an angle in radians: \n";
    cin >> degree;
    radian = degree * (PI/180);//chage radian to degree
}

void showCos(double radian)//calculate cos
{
    double dcos;
    ofstream cosine;
    cosine.open("cosine.txt",fstream::app);
    dcos =cos(radian);
    cout << "Cosine is " << dcos << "\n";
    cosine << "Cosine is " << dcos << "\n";
    cosine.close();
}
void showSin(double radian)//calculate sin
{
    double dsine;
    ofstream sine;
    sine.open("sine.txt",fstream::app);
    dsine =sin(radian);
    cout << "Sine is " << dsine << "\n";
    sine << "Sine is " << dsine << "\n";
    sine.close();
}

void showTan(double radian)//calculate tan
{
    double dtan;
    ofstream tangent;
    tangent.open("tangent.txt",fstream::app);
    dtan =tan(radian);
    cout << "Tangent is " << dtan << "\n";
    tangent << "Tangent is " << dtan << "\n";
    tangent.close();
}

void showCosec(double radian)//calculate cosec
{
    double dcosec;
    ofstream cosec;
    cosec.open("cosecant.txt",fstream::app);
    dcosec = 1/cos(radian);
    cout << "Cosecant is " << dcosec << "\n";
    cosec << "Cosecant is " << dcosec << "\n";
    cosec.close();
}

void showSec(double radian)//calculate sec
{
    double dsec;
    ofstream sec;
    sec.open("secant.txt",fstream::app);
    dsec = 1/sin(radian);
    cout << "Secant is " << dsec << "\n";
    sec << "Secant is " << dsec << "\n";
    sec.close();
}

void showCot(double radian)//calculate cot
{
    double dcot;
    ofstream cot;
    cot.open("cotangent.txt",fstream::app);
    dcot = 1/tan(radian);
    cout << "Cotangent is " << dcot << "\n";
    cot << "Cotangent is " << dcot << "\n";
    cot.close();
}

void calcElectricCharge(float &current, float &time)//calculate electic charge
{
    float EC;
    ofstream ec;
    ec.open("ec.txt",fstream::app);
    EC = (current*time);

    cout<<"The value of Electric charge is: "<<EC<<"C"<<endl;
    ec<<"The value of Electric charge is: "<<EC<<"C"<<endl;

    ec.close();

}

void calcCapacitance(float &Q,float &V)//calculate capacitance
{
    double Capacitance;
    ofstream cap;
    cap.open("cap.txt",fstream::app);
    Capacitance = Q/V;

    cout<<"The value of Capacitance is : "<<Capacitance<<"F"<<endl;
    cap<<"The value of Capacitance is : "<<Capacitance<<"F"<<endl;

    cap.close();

}

void calcVoltage(float &current,float &resistance)//calculate voltage
{
    float Voltage;
    ofstream volt;
    volt.open("voltage.txt",fstream::app);
    Voltage = current*resistance;

    cout<<"The value of Voltage is: "<<Voltage<<"V"<<endl;
    volt<<"The value of Voltage is: "<<Voltage<<"V"<<endl;

    volt.close();

}

void calcPower(float &current,float &resistance)//calculate power
{
    float P;
    ofstream pwr;
    pwr.open("power.txt",fstream::app);
    P = pow(current,2)*resistance;

    cout<<"The value of Power is: "<<P<<"W"<<endl;
    pwr<<"The value of Power is: "<<P<<"W"<<endl;

    pwr.close();

}

void calcCurrent(float &voltage,float &resistance)//calculate current
{
    float current;
    ofstream curr;
    curr.open("current.txt",fstream::app);
    current = voltage/resistance;

    cout<<"The value of Current is: "<<current<<"A"<<endl;
    curr<<"The value of Current is: "<<current<<"A"<<endl;

    curr.close();
}

void getDimension(rectangle &box,circle &circle1)//get the dimesnsion for circle and rectangle
{
    cout << "Enter the radius of a circle: ";
    cin >> circle1.radius;

    cout << "\nEnter the length of a rectangle: ";
    cin >> box.length;           // read in the length member of box

    cout << "\nEnter the width of a rectangle: ";
    cin >> box.width;           // read in the width member of box

    cout << "\nEnter the height of a rectangle: ";
    cin >> box.height;
}

void showDimension(rectangle box,circle circle1)//show the dimension of circl and rectangle
{
    ofstream dim;
    dim.open("dimension.txt",fstream::app);

    circle1.area = PI * pow(circle1.radius,2);//compute area circle
    circle1.perimeter = (2 * PI * circle1.radius);//compute perimeter circle
    circle1.volume = static_cast<double>(4)/3 * PI * pow(circle1.radius,3);//compute volume circle

    cout << fixed << showpoint << setprecision(2);
    cout << "\nThe area of the circle is " << circle1.area <<endl;
    cout << "\nThe perimeter of the circle is " << circle1.perimeter << endl;
    cout << "\nThe volume of the circle is " << circle1.volume <<endl;

    dim << "\nThe area of the circle is " << circle1.area <<endl;
    dim << "\nThe perimeter of the circle is " << circle1.perimeter << endl;
    dim << "\nThe volume of the circle is " << circle1.volume <<endl;

    box.area = box.length * box.width;              // compute the area member of box
    box.perimeter = 2 * box.length + 2 * box.width;// compute the perimeter member of box
    box.volume = box.length * box.width * box.height; // compute the volume member of box

    cout << fixed << showpoint << setprecision(2);

    cout << "\nThe area of the rectangle is " << box.area <<endl;
    cout << "\nThe perimeter of the rectangle is " << box.perimeter << endl;
    cout << "\nThe volume of the rectangle is " << box.volume <<endl;

    dim << "\nThe area of the rectangle is " << box.area <<endl;
    dim << "\nThe perimeter of the rectangle is " << box.perimeter << endl;
    dim << "\nThe volume of the rectangle is " << box.volume <<endl;

    dim.close();
}


void eqtroot(float a, float b, float c)//Solve root of quadratic equation
{
    ofstream root;
    root.open("Quadratic.txt",fstream::app);//open file root

    float P,x1,x2;
    P = (b*b)-(4*a*c);
    if (P>0)//for thwo real root
    {
        x1 = (-b + sqrt(P))/ (2*a);
        x2 = (-b - sqrt(P))/ (2*a);

        cout << " There are two real Roots." << endl;
        cout << "x1 = " << x1 << endl;
        cout << "x2 = " << x2 << endl;
        root << " There are two real Roots." << endl;
        root << "x1 = " << x1 << endl;
        root << "x2 = " << x2 << endl;
    }

    if (P<0)//for no real root
    {
        cout << "there is no real root."  << endl;
        root << "there is no real root."  << endl;
    }

    if (P==0)//for one real root
    {
        cout << "there is one real root." << endl;
        root << "there is one real root." << endl;
        x1 = (-b + sqrt(P)) / (2*a);
        cout << "x1 = x2 =" << x1 << endl;
        root << "x1 = x2 =" << x1 << endl;
    }

    root.close();//close file root
}

# data[].attributes.body
RIMBA BARA
MOHAMAD ASHRAF B MD GHARIF
MUHAMMAD AMIRUL B ROSLI
MUHAMMAD SYUKRI HAKIM B NOR MUHAMAD

# data[].attributes.body
LILO&STITCH
FARAH NATASHA BT AZREEN
FATIN AQILAH BT MOHD ISKANDAR

# data[].attributes.body
TRIPLE A
AKID BIN AZMAN
AZHAR BIN MOHD ISMAIL
MOHAMAD AFIQ BIN OMAR

# data[].attributes.body
TRIPLE A
AKID BIN AZMAN
AZHAR BIN MOHD ISMAIL
MOHAMAD AFIQ BIN OMAR

# data[].attributes.body
AHMAD FARHAN
AHMAD DANIEL HAIKAL
ABDUL AZIM

# data[].attributes.body
MUHAMMAD FIRDAUS
MUHAMMAD FARHAN
MUHAMMAD SYAZWAN

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include <cmath>
#include <windows.h>
#include<iomanip>
#include<stdlib.h>
#include<fstream>
using namespace std;
const double PI = 3.142;
const double pi = 3.142;
void dispMenu();//function prototype: display menu use void function
void add(); //function prototype: program number 1 use void function
void sub();//function prototype: program number 1 use void function
void mul();//function prototype: program number 1 use void function
void div();//function prototype: program number 1 use void function

unsigned long convtodecinum(char hexa[]);//unsigned long for program 3

void calcTrigo(double &,double &,double &,double &,double &,double &,
               double &,double &,double &,double &,double &,double &);//function prototype: pass by reference (alias) for calculate trigonometric
void dispTrigo(double &,double &,double &,double &,double &,double &,
               double &,double &,double &,double &,double &,double &);//function prototype: pass by reference (alias) for calculate trigonometric
struct rectangle //function prototype: structure for program number 6
{
   float length; //structure member
   float width;//structure member
   float height;//structure member
   float area;//structure member
   float perimeter;//structure member
   float volume;//structure member
};

struct circle//function prototype: structure for program number 6
{
   float radius;//structure member
   float areaC;//structure member
   float circumference;//structure member
   float volumeC;//structure member
};

void findRoot(float, float, float);//function prototype: void function program number 7

int main(){
    ofstream gerakluFile;//file for outfile
    ifstream masukFile;//file for infile
    gerakluFile.open("memorypad.txt",fstream::app);//open file definition for create txt and the memory not delete the previous memory

    string hismemo;
    //definition of int,char,double
    int calcProg, choiceNum6,i,j,row,col, first[10][10], second[10][10], sum[10][10], subtract[10][10], multiply[10][10]// 2D array definition in matrices program
    ,chooceTrigo,redoexit;
    char operation,progRoot;
    double angle1, angle2, angle3,angle4, angle5, angle6, result1, result2, result3, result4, result5, result6;
    float a, b, c,cap,volt,eleq,curr,res,power;
        char convertValues,hexdecnum[100],binnum[100], hexadeci[100];
        int A,B,C,D,E,F,Q,S,R,h=1, k,n, temp,integer,arr[100],redoProg;
        long int decnum, rem, quot,z=0,binval,hexaval=0,l=1,remainder;
        unsigned long L,M,num=0,P;
    pMenu:dispMenu();//function for display menu
do//repitition using do while
{

    cout<<"Please select what you want to calculate: \n Choose: "<<endl;
    cin>>calcProg;
    system("cls");
}
while ((calcProg<1)||(calcProg>8));//repetition using do while for 1 to 8 program
    //program for matrices using 2D array program
    if(calcProg ==1 ){
    p:cout << "please select your operation :" << endl;
    cout << "1. addition" << endl;
    cout << "2. subtraction" << endl;
    cout << "3. multiplication" << endl;
    cout << "4. division" << endl;
    cout << "please enter your operation by number :" << endl;
    cin >> operation;
    system("cls");
        switch (operation)//control flow for scalar values
        {

            case '1' : add();
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto p;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 1\n";
                        }
                        else{
                            goto p;
                        }

            break;
            case '2' : sub();
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto p;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 1\n";
                        }
                        else{
                            goto p;
                        }
            break;
            case '3' : mul();
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto p;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 1\n";
                        }
                        else{
                            goto p;
                        }
            break;
            case '4' : div();
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto p;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 1\n";
                        }
                        else{
                            goto p;
                        }
            break;
            default  :
            cout << "\aInvalid operation" << endl;
            goto p;
    }
    }
    //program for matrices using 2D array program
    else if(calcProg ==2 ){

    pProg2:cout << "Enter the number of rows and columns of matrices : "<<endl;
    gerakluFile<< "Enter the number of rows and columns of matrices : "<<endl;
    cin >> row >> col;
    gerakluFile<<"Row = "<<row<<" and Column = "<<col<<endl;

    cout << "\nEnter the elements of first matrrices : "<<endl;
    gerakluFile<<"\nEnter the elements of first matrrices : "<<endl;

    for (i=0;i<row;i++ )
    {
    for (j=0;j<col;j++ )
    {
    cin >> first[i][j];
    gerakluFile<<first[i][j]<<endl;
}
}
cout << "Enter the elements of second matrix\n"<<endl;
gerakluFile<<"Enter the elements of second matrix\n"<<endl;
for (i= 0 ;i< row ;i++ )
{
for (j= 0;j<col;j++ )
{
cin >> second[i][j];
gerakluFile<<second[i][j]<<endl;
}
}
for (i=0;i< row;i++ )
{
for (j=0;j<col;j++ )
{
sum[i][j] = first[i][j] + second[i][j];
subtract[i][j] = first[i][j] - second[i][j];
multiply[i][j] = first[i][j] * second[i][j];
}
}
cout << "\nSum of entered matrices : "<<endl;
gerakluFile<<"\nSum of entered matrices : "<<endl;
for (i=0 ; i < row ; i++ )//nested loop
{
for ( j = 0 ; j < col ; j++ )
{
cout << sum[i][j] << "\t";
gerakluFile<<sum[i][j] << "\t";

}
cout << endl;
gerakluFile<<endl;
}
cout << "\nSubtraction of entered matrices : "<<endl;
gerakluFile<<"\nSubtraction of entered matrices : "<<endl;
for (i=0 ; i < row ; i++ )
{
for ( j = 0 ; j < col ; j++ )
{
cout << subtract[i][j] << "\t";
gerakluFile<<subtract[i][j] << "\t";
}
cout << endl;
gerakluFile<<endl;
}
cout << "\nMultiplication of entered matrices : "<<endl;
gerakluFile<<"\nMultiplication of entered matrices : "<<endl;
for (i=0 ; i <row ; i++ )
{
for ( j = 0 ; j < col ; j++ )
{
cout << multiply[i][j] << "\t";
gerakluFile<<multiply[i][j] << "\t";
}
cout << endl;
gerakluFile<<endl;

}
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pProg2;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 2\n";
                        }
                        else{
                            goto pProg2;
                        }
    }
    //program for conversion base using control flow swicth case

     else if(calcProg==3){


    pProg3:cout<<"\nChoose which one you want to convert: "<<endl;
    cout << "\nA - Convert decimal to binary       :" << endl;
    cout << "B - Convert decimal to hexadecimal  :" << endl;
    cout << "C - Convert binary to decimal       :" << endl;
    cout << "D - Convert binary to hexadecimal   :" << endl;
    cout << "E - Convert hexadecimal  to decimal :" << endl;
    cout << "F - Convert hexadecimal  to binary  :" << endl;
    cin >>convertValues;

    switch(convertValues)
    {
    case 'A':

    cout<<"Enter an integer in decimal number system : "<<endl;
    gerakluFile<<"Enter an integer in decimal number system : "<<endl;
    cin>> R;
    gerakluFile<<"Decimal = "<<R<<endl;
    cout<<"In binary number system is: ";
    gerakluFile<<"\nIn binary number system is: ";
    for (Q = 3; Q >= 0; Q--)
    {
       S = R >> Q;
        if (S & 1){
         cout<<"1";
         gerakluFile<<"1";
        }
        else{
         cout<<"0";
         gerakluFile<<"0";

  }
    }


    break;

    case 'B':

        cout<<"Enter an integer in decimal number system : ";
        gerakluFile<<"\nEnter an integer in decimal number system : "<<endl;
	    cin>>decnum;
	    gerakluFile<<"Decimal = "<<decnum<<endl;
	    quot=decnum;
	    while(quot!=0)
	      {
		   temp=quot%16;
		// to convert integer into character
		   if(temp<10){
			   temp=temp+48; }
		    else{
               temp=temp+55; }

		       hexdecnum[h++]=temp;
		       quot=quot/16; }

     	cout<<"In hexadecimal value system is: " ;
     	gerakluFile<<"\nIn hexadecimal value system is: " ;
	      for(k=h-1; k>0; k--) {
		    cout<<hexdecnum[k];
		    gerakluFile<<hexdecnum[k]<<endl;
	      }

        break;

    case 'C':
         cout<<"Enter an integer in binary number system: ";
         gerakluFile<<"\nEnter an integer in binary number system: ";
         cin>>M;
         gerakluFile<<"Binary = "<<M<<endl;
         cout<<"In decimal value system is: ";
         gerakluFile<<"\nIn decimal value system is: ";

        for(L=0;M!=0;++L)
          {
           P=M%10;
           num=(P)*(pow(2,L))+num;
           M=M/10;
          }
    cout<<num;
    gerakluFile<<num<<endl;

     break;

case 'D':

        {
            long int answer=0;
            string binNumber;
            cout<<"Enter an integer in binary number system: ";
            gerakluFile<<"\nEnter an integer in binary number system: ";
            cin>> binNumber;
            gerakluFile<<"Binary = "<<binNumber<<endl;
            int len=binNumber.size();
            for(int i=0;i<len;i++)
            {

                answer+=(binNumber[len-i-1]-48)*pow(2,i);
            }
        cout<<setbase(16);
        gerakluFile<<setbase(16);
        cout<<"In hexadecimal value system is : ";
        gerakluFile<<"\nIn hexadecimal value system is : ";
        cout<<answer;
        gerakluFile<<answer<<endl;
        }

  break;

    case 'E':

       cout<<"Entex a hexadecimal number system: "<<endl;
       gerakluFile<<"\nEntex a hexadecimal number system: "<<endl;
       cin >>hex >> integer;

       cout << "In decimal value system is: " <<integer <<endl;
       gerakluFile<< "\nconvert hexadecimal to decimal: " <<hex <<endl;
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pProg3;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 3\n";
                        }
                        else{
                            goto pProg3;
                        }
     break;

    case 'F':

       cout<<"Enter a hexadecimal number system : ";
	   cin>>hexadeci;
	   cout<<"In binary number system is : ";
	   gerakluFile<<"\nconvert hexadecimal to binary: "<<hexadeci[z];
	     while(hexadeci[z])
	     {
		  switch(hexadeci[z])
		   {
			case '0' : cout<<"0000";
                        gerakluFile<<"0000"<<endl; break;
			case '1' : cout<<"0001";
                        gerakluFile<<"0001"<<endl; break;
			case '2' : cout<<"0010";
                        gerakluFile<<"0010"<<endl; break;
			case '3' : cout<<"0011";
                        gerakluFile<<"0011"<<endl; break;
			case '4' : cout<<"0100";
                        gerakluFile<<"0100"<<endl; break;
			case '5' : cout<<"0101";
                        gerakluFile<<"0101"<<endl; break;
			case '6' : cout<<"0110";
                        gerakluFile<<"0110"<<endl; break;
			case '7' : cout<<"0111";
                        gerakluFile<<"0111"<<endl; break;
			case '8' : cout<<"1000";
                        gerakluFile<<"1000"<<endl; break;
			case '9' : cout<<"1001";
                        gerakluFile<<"1001"<<endl; break;
			case 'A' : cout<<"1010";
                        gerakluFile<<"1010"<<endl; break;
			case 'B' : cout<<"1011";
                        gerakluFile<<"1011"<<endl; break;
			case 'C' : cout<<"1100";
                        gerakluFile<<"1100"<<endl; break;
			case 'D' : cout<<"1101";
                        gerakluFile<<"1101"<<endl; break;;
			case 'E' : cout<<"1110";
                       gerakluFile<<"1110"<<endl; break;
			case 'F' : cout<<"1111";
                       gerakluFile<<"1111"<<endl; break;
			case 'a' : cout<<"1010";
                       gerakluFile<<"1010"<<endl; break;;
			case 'b' : cout<<"1011";
                        gerakluFile<<"1011"<<endl; break;
			case 'c' : cout<<"1100";
                       gerakluFile<<"1100"<<endl; break;
			case 'd' : cout<<"1101";
                        gerakluFile<<"1101"<<endl; break;
			case 'e' : cout<<"1110";
                       gerakluFile<<"1110"<<endl; break;
			case 'f' : cout<<"1111";
                       gerakluFile<<"1111"<<endl; break;
            default : cout<<"\nInvalid hexadecimal digit "<<hexadeci[z]<<endl;
                        gerakluFile<<"\nInvalid hexadecimal digit "<<hexadeci[z]<<endl;
		}
	     	z++;
	}

	break;
          default:
          cout <<"INVALID CONVERSION \n";
          gerakluFile<<"INVALID CONVERSION \n";
            goto pProg3;
            break;
    }

                         cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pProg3;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 3\n";
                        }
                        else{
                            goto pProg3;
                        }

    }
    //program for trigonometric
     else if(calcProg ==4 ){
        gerakluFile.open("memorypad.txt",ios::out|ios::app);
    pProg4:cout<<"Please select your Trigonometri equation :\n";
    cout <<"Enter Degree angle1 for sin: ";
    cin >> angle1;
    cout <<"Enter Degree angle2 for cos: ";
    cin >> angle2;
    cout <<"Enter Degree angle3 for tan: ";
    cin >> angle3;
    cout <<"Enter Degree angle4 for cosec: ";
    cin >> angle4;
    cout <<"Enter Degree angle5 for sec: ";
    cin >> angle5;
    cout <<"Enter Degree angle6 for cot: ";
    cin >> angle6;
    calcTrigo(angle1,angle2,angle3,angle4,angle5,angle6,
              result1,result2,result3,result4,result5,result6);
    dispTrigo(angle1,angle2,angle3,angle4,angle5,angle6,
              result1,result2,result3,result4,result5,result6);

                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pProg4;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 4\n";
                        }
                        else{
                            goto pProg4;
                        }


    }
        //program for program 5 using control flow swicth case
     else if(calcProg ==5 ){

    pProg5: cout << "please choose what you want to calculate" << endl;
    cout << "1. electrical charge" << endl;
    cout << "2. capacitance" << endl;
    cout << "3. current" << endl;
    cout << "4. voltage"<< endl;
    cout << "5. power" << endl;
    cout << "please enter the number :" << endl;
    cin>>progRoot;
    system("cls");

    switch(progRoot)
    {
      case '1' : cout << "enter your capasitor(C) value" << endl;
                 gerakluFile<<"\nYour capasitor(C) value: " << endl;
                 cin >> cap;
                 gerakluFile<<cap<<endl;
                 cout << "enter your voltage(V) value" << endl;
                 gerakluFile<<"\nYour voltage(V) value: " << endl;
                 cin >> volt;
                 gerakluFile<<volt<<endl;

                 eleq = cap * volt;
                 cout << "your electrical charge(Q) value is : " << eleq << " C" << endl;
                 gerakluFile<<"\nyour electrical charge(Q) value is : " << eleq << " C" << endl;
                 break;

      case '2' : cout << "enter your charge(Q) value" << endl;
                    gerakluFile<<"\nYour charge(Q) value: " << endl;
                 cin >> eleq;
                 gerakluFile<<eleq<<endl;
                 cout << "enter your voltage(V) value" << endl;
                 cin >> volt;
                 gerakluFile<<"\nYour voltage(V) value: " <<volt<< endl;
                 cap = eleq / volt;
                 cout << "your capacitor(C) value is : " << cap << " F" << endl;
                 gerakluFile<<"your capacitor(C) value is : " << cap << " F" << endl;
                 break;

      case '3' : cout << "enter your voltage(V) value" << endl;

                 cin >> volt;
                 gerakluFile<<"\nyour voltage(V) value: " << volt<<endl;
                 cout << "enter your resistor(R) value" << endl;
                 cin >> res;
                 gerakluFile<<  "\nYour resistor(R) value" <<res<< endl;
                 curr = volt / res;
                 cout << "your current(I) value is : " << curr << " A" << endl;
                 gerakluFile<<"\nYour current(I) value is : " << curr << " A" << endl;
                 break;

      case '4' : cout << "enter your current(I) value" << endl;
                 cin >> curr;
                 gerakluFile<<"enter your current(I) value: " <<curr<< endl;
                 cout << "\nYour resistor(R) value" << endl;
                 cin >> res;
                 gerakluFile<<"\nYour resistor(R) value: " <<res<< endl;
                 volt = curr * res;
                 cout << "your voltage(V) value is : " << volt << " V" << endl;
                    gerakluFile<<"your voltage(V) value is : " << volt << " V" << endl;
                 break;

      case '5' : cout << "enter your current(I) value" << endl;
                 cin >> curr;
                 gerakluFile<<"\nYour current(I) value: " <<curr<< endl;
                 cout << "enter your voltage(V) value" << endl;
                 cin >> volt;
                 gerakluFile<<"\nYour voltage(V) value: " <<volt<< endl;
                 power = curr * volt;
                 cout << "your power(P) value is : " << power << " W" << endl;
                 gerakluFile<<"your power(P) value is : " << power << " W" << endl;
                 break;

      default :  cout << "\aInvalid number" << endl;
                    gerakluFile<<"\nInvalid number" << endl;
                 goto pProg5;
    }
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pProg5;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 5\n";
                        }
                        else{
                            goto pProg5;
                        }
    }
        //program for rectangle and circle using structure
    else if(calcProg ==6 ){
    pNum6:cout << "Choose whether you wanted to calculate the perimeter/circumference\n"
        << " of a rectangle or a circle" << endl
        << "1.Rectangle\n" << "2.Circle" << endl << endl;

        cin >> choiceNum6;
        system("cls");

   if(choiceNum6==1)
   {
   rectangle box;

   cout << "Enter the length of a rectangle: ";
   cin >> box.length;

   cout << "Enter the width of a rectangle: ";
   cin >> box.width;

   cout << "Enter the height of a rectangle: ";
   cin >> box.height;

   cout << endl << endl;

   box.area = box.length * box.width;
   box.perimeter = 2 * box.length + 2 * box.width;
   box.volume = box.length * box.width * box.height;

   cout << fixed << showpoint << setprecision(2);

   cout << "The area of the rectangle is " << box.area <<endl;
   gerakluFile<<"\nThe area of the rectangle is " << box.area <<endl;
   cout << "The perimeter of the rectangle is " << box.perimeter << endl;
   gerakluFile<<"\nThe perimeter of the rectangle is " << box.perimeter << endl;
   cout << "The volume of the rectangle is " << box.volume << endl;
   gerakluFile<<"The volume of the rectangle is " << box.volume << endl;
   }

   else if(choiceNum6==2)
   {
        circle ball;

   cout << "Enter radius of the circle: ";
   cin >> ball.radius;

   cout << endl << endl;

   ball.areaC = PI*ball.radius*ball.radius;
   ball.circumference = 2*PI*ball.radius;
   ball.volumeC = (4*PI*ball.radius*ball.radius*ball.radius)/3;

   cout << fixed << showpoint << setprecision(2);

   cout << "The area of the circle is " << ball.areaC <<endl;
   gerakluFile<<"\nThe area of the circle is " << ball.areaC <<endl;
   cout << "The circumference of the circle is " << ball.circumference << endl;
   gerakluFile<<"The circumference of the circle is " << ball.circumference << endl;
   cout << "The volume of the circle is " << ball.volumeC << endl;
   gerakluFile<<"The volume of the circle is " << ball.volumeC << endl;
   }
   else{
    cout<<"\aInvalid\n\n";
    gerakluFile<<"\aInvalid\n\n";
    goto pNum6;
   }

                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pNum6;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 6\n";
                        }
                        else{
                            goto pNum6;
                        }
    }
        //program for finding root using void function
    else if(calcProg ==7 ){
    pProg7:cout << "Please enter the value of a, b and c:";
    cin >> a >> b >> c;
    cout << "Your quadratic function is: "<<a<<"x^2+"<<b<<"x+"<<c<<endl;
    gerakluFile<<"\nYour quadratic function is: "<<a<<"x^2+"<<b<<"x+"<<c<<endl;
    cout << "Now this program will find its roots.... "<<endl;
    findRoot(a, b, c);
                        cout<<"\n\nDo you want to calculate again?\n";
                        cout<<"1 to calculate again and 0 to continue\n";
                        cin>>redoProg;
                        system("cls");
                        if(redoProg==1){
                            goto pProg7;
                        }
                        else if(redoProg==0){
                            cout<<"Exit program 1\n";
                        }
                        else{
                            goto pProg7;
                        }
    }
        //program for history
    else if(calcProg ==8 ){
    masukFile.open("memorypad.txt");
    while(getline(masukFile,hismemo))
    cout<<hismemo<<endl;
        masukFile.close();
    int proceed;
    proceed:cout<<"Press 1 for continue and 0 for exit from history...\n"<<endl;
    cin>>proceed;
    system("cls");
    if(proceed==1){
    goto pMenu;
    }
    else if(proceed==0){
        cout<<"Exit from history";
    }
    else
    {
        cout<<"Invalid..."<<endl;
        goto proceed;
    }

    }

    cout<<"\n\n\t\t\tThank you!\n";
    redo:cout<<"Do you want to perform another calculation?\n"
    <<"Press 1 to continue and 0 to exit\n";
    cin>>redoexit;
    system("cls");
    if(redoexit==1){
        goto pMenu;
    }
    else if(redoexit==0)
    {
               for (int i=0;i<=79;i++)
   {
       cout<<"*";
       Sleep(10);
   }cout<<endl;
        cout<<"Thank you for using FFW e-Calculator\n\n";
               for (int i=0;i<=79;i++)
   {
       cout<<"*";
       Sleep(10);
   }
    }
    else {
        cout<<"Invalid\n\a";
        goto redo;
    }
    gerakluFile.close();


return 0;
}

//function definition for display menu
void dispMenu()
{
       for (int i=0;i<=79;i++)
   {
       cout<<"*";
       Sleep(10);
   }
   cout<<endl;
    cout<<"\t\t\tWelcome ";
    Sleep(100);
    cout<<"to ";
    Sleep(100);
    cout<<"FFW ";
    Sleep(100);

    cout<<"Calculator\n\n";
       for (int i=0;i<=79;i++)
   {
       cout<<"*";
       Sleep(10);
   }
    cout<<"1) +,-,x,/ operation of scalar values."<<endl;
    cout<<"2) +,-,x of matrices."<<endl;
    cout<<"3) Conversion between binary, hexadecimal,decimal values."<<endl;
    cout<<"4) Trigonometric operation."<<endl;
    cout<<"5) Electrical charge, Capacitance, Current, Voltage and Power."<<endl;
    cout<<"6) Perimeter/Circumference, Area and Volume of rectangle and circles."<<endl;
    cout<<"7) Roots of quadratic equations."<<endl;
    cout<<"8) Your calculation history."<<endl<<endl;

}
//function definition for addition
void add()
{
    ofstream gerakluFile;
    gerakluFile.open("memorypad.txt",fstream::app);
    int sum=0;
    int arrayname[2];
        cout << "Sum of two numbers" << endl;
        gerakluFile<<"Sum of two numbers"<< endl;
        cout <<"please enter two integer :"<< endl;
        gerakluFile<<"please enter two integer :" << endl;
        cin>>arrayname[0];
        cin>>arrayname[1];
        gerakluFile<<arrayname[0]<<" + ";
        gerakluFile<<arrayname[1]<<endl;
        for (int a=0; a<2; a++)
        {
			sum+=arrayname[a];
        }

        cout <<"your answer is :" << sum << endl;
        gerakluFile<<"your answer is :" << sum << endl<<endl;

}
void sub()//function definition for subtraction
{
    ofstream gerakluFile;
    gerakluFile.open("memorypad.txt",fstream::app);
    int sub=0;
    int arrayname[2];
        cout << "Substraction of two numbers" << endl;
        gerakluFile<<"Substraction of two numbers"<< endl;
        cout << "please enter two integer :" << endl;
        gerakluFile<<"please enter two integer :" << endl;
        cin>>arrayname[0];
        cin>>arrayname[1];
        gerakluFile<<arrayname[0]<<" - ";
        gerakluFile<<arrayname[1]<<endl;

        sub = arrayname[0];
        arrayname[0] = 0;
        for (int a=0; a<2; a++)
        {
			sub-=arrayname[a];
        }

        cout <<"your answer is :" << sub << endl;
        gerakluFile<<"your answer is :" << sub << endl<<endl;
}


void mul()//function definition for  multiplication
{
    ofstream gerakluFile;
    gerakluFile.open("memorypad.txt",fstream::app);
    int mul=0;
    int arrayname[2];
        cout << "Multification of two numbers" << endl;
        gerakluFile<<"Multification of two numbers"<< endl;
        cout << "please enter two integer :" << endl;
        gerakluFile<<"please enter two integer :" << endl;
        cin>>arrayname[0];
        cin>>arrayname[1];
        gerakluFile<<arrayname[0]<<" x ";
        gerakluFile<<arrayname[1]<<endl;
        mul = arrayname[0];
        arrayname[0] = 1;
        for (int a=0; a<2; a++)
        {
			mul*=arrayname[a];
        }

        cout <<"your answer is :" << mul << endl;
         gerakluFile<<"your answer is :" << mul << endl<<endl;
}
void div()//function definition for division
{
    ofstream gerakluFile;
    gerakluFile.open("memorypad.txt",fstream::app);
    float div=0;
    int arrayname[2];
        cout << "Division of two numbers" << endl;
        gerakluFile<<"Division of two numbers"<< endl;
        cout << "please enter two integer :" << endl;
        gerakluFile<<"please enter two integer :" << endl;
        cin>>arrayname[0];
        cin>>arrayname[1];
        gerakluFile<<arrayname[0]<<" / ";
        gerakluFile<<arrayname[1]<<endl;
        div = arrayname[0];
        arrayname[0] = 1;
        for (int a=0; a<2; a++)
        {
			div/=arrayname[a];
        }

        cout <<"your answer is :" << div << endl;
        gerakluFile<<"your answer is :" << div << endl<< endl;
}
//function definition for trigonometric using function pass by reference alias for calculate
void calcTrigo(double &angle1,double &angle2,double &angle3,double &angle4,double &angle5,double &angle6,
               double &result1,double &result2,double &result3,double &result4,double &result5,double &result6)
{
    result1 = sin (angle1*(pi/180) );
    result2 = cos (angle2*(pi/180) );
    result3 = tan (angle3*(pi/180) );
    result4= 1/(sin (angle4*(pi/180) ));
    result5 = 1/(cos (angle5*(pi/180) ));
    result6 = 1/(tan (angle6*(pi/180) ));
}
//function definition for trigonometric using function pass by reference alias for display
void dispTrigo(double &angle1,double &angle2,double &angle3,double &angle4,double &angle5,double &angle6,
               double &result1,double &result2,double &result3,double &result4,double &result5,double &result6)
{
    ofstream gerakluFile;
    gerakluFile.open("memorypad.txt",fstream::app);
    cout <<" when angle1 = "<< angle1 <<", sin angle1 = "<<result1<<endl;
    gerakluFile<<" when angle1 = "<< angle1 <<", sin angle1 = "<<result1<<endl;
    cout <<" when angle2 = "<< angle2 <<", cos angle2 = "<<result2<<endl;
    gerakluFile<<" when angle2 = "<< angle2 <<", cos angle2 = "<<result2<<endl;
    cout <<" when angle3 = "<< angle3 <<", tan angle3 = "<<result3<<endl;
    gerakluFile<<" when angle3 = "<< angle3 <<", tan angle3 = "<<result3<<endl;
    cout <<" when angle4 = "<< angle4 <<", cosec angle4 = "<<result4<<endl;
    gerakluFile<<" when angle4 = "<< angle4 <<", cosec angle4 = "<<result4<<endl;
    cout <<" when angle5 = "<< angle5 <<", sec angle5 = "<<result5<<endl;
    gerakluFile<<" when angle5 = "<< angle5 <<", sec angle5 = "<<result5<<endl;
    cout <<" when angle6 = "<< angle6 <<", cot angle6 = "<<result6<<endl;
    gerakluFile<<" when angle6 = "<< angle6 <<", cot angle6 = "<<result6<<endl;
    gerakluFile.close();
}
//function definition for find root using void function
void findRoot(float a, float b, float c)
{
    ofstream gerakluFile;
    gerakluFile.open("memorypad.txt",fstream::app);
   cout <<"Computing roots";
   for (int i=0;i<=5;i++)
   {
       cout<<".";
       Sleep(500);
   }
   cout << endl;
   float p;
   float root1, root2;
   p = pow(b,2)-4*a*c;
   if (p<0)
   {
       cout <<"There is no real root"<<endl;
       gerakluFile<<"There is no real root"<<endl;
   }

   if (p>0)
   {
        cout << "There are two real roots"<<endl;
        gerakluFile<<"There are two real roots"<<endl;
        root1 = (-b+sqrt(p))/(2*a);
        root2 = (-b-sqrt(p))/(2*a);
        cout << "The roots are : "<<root1<<" and "<<root2<<endl;
        gerakluFile<<"The roots are : "<<root1<<" and "<<root2<<endl;
   }

   if (p==0)
   {
       cout <<"There is one real root"<<endl;
       gerakluFile<<"There is one real root"<<endl;
       root1 = (-b+p)/(2*a);
       cout << "The root is : "<<root1<<endl;
       gerakluFile<<"The root is : "<<root1<<endl;
   }
       gerakluFile.close();
}

# data[].attributes.body
MUHAMMAD FIRDAUS
MUHAMMAD FARHAN
MUHAMMAD SYAZWAN

# data[].attributes.body
MUHAMMAD FIRDAUS MUHAMMAD FARHAN MUHAMMAD SYAZWAN SYAFIQ

# data[].attributes.body
MUHAMMAD FIRDAUS MUHAMMAD FARHAN MUHAMMAD SYAZWAN SYAFIQ

# data[].attributes.body
DOUBLE A
ANIS ALYANI
NUR ZAHIDAH ALIAH

# data[].attributes.body
DOUBLE A
ANIS ALYANI
NUR ZAHIDAH ALIAH

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include<iomanip>
#include<cmath>
#include<windows.h>
#include<stdlib.h>
#include<string>
#include<fstream>
using namespace std;


const double pi = 3.142;

int tambah (int,int);
int tolak (int, int);
int kali (int, int);
int bahagi (int,int);

unsigned long convtodecinum(char hexa[]);

void computeQuad(int&,int&,int&);
void displayMenu();

struct object
{
   double panjang,
          lebar,
          tinggi,
          radius,
          circumference,
          perimeter,
          luas,
          isipadu;
};


int main ()
{

    ofstream outFile;
    ifstream AAFile;
    string sejarah;
    outFile.open("alianis.txt",fstream::app);


outFile << "\t\t------------------------------------------------------------------------------\t\t" << endl;
outFile <<   "\t\tTHIS "; Sleep(200);
outFile <<   " PROGRAM "; Sleep(200);
outFile <<   " WILL "; Sleep(200);
outFile <<   " DEVELOP "; Sleep(200);
outFile <<   " AN "; Sleep(200);
outFile <<   " ENGINEERING "; Sleep(200);
outFile <<   " CALCULATOR "; Sleep(200);
outFile <<   " WITH "; Sleep(200);
outFile <<   " 7 "; Sleep(200);
outFile <<   " OPERATIONS "<<endl;

outFile << "\t\t------------------------------------------------------------------------------\t\t" << endl;
outFile << endl;
outFile << " \t\tPLEASE CHOOSE THE OPERATION THAT YOU WANT TO USE:\t\t"<< endl;
outFile << "\n\t\t1. Addition,subtraction, multiplication and division operations of scalar values\t\t" << endl;
outFile << "\t\t2. Addition, subtraction and multiplication of matrices\t\t" << endl;
outFile << "\t\t3. Conversion between Binary values, Hexadecimal Values and Decimal Values\t\t " << endl;
outFile << " \t\t4. Trigonometric operation\t\t" << endl;
outFile << " \t\t5. Electrical Charge, Capacitance, Current, Voltages and Power\t\t " << endl;
outFile << " \t\t6. Perimeter/Circumference, Area and Volume of rectangles and circles\t\t "<< endl;
outFile << " \t\t7. Roots of quadratic equation\t\t" << endl;
outFile << " \t\t8. History\t\t" << endl;


char redo;

do
    {
     gomenu:displayMenu();
     int choose;

     cout << "Please choose:";
     cin >> choose;
     system("cls");
     if (choose==1)
{
    cout << "\n\t______________________________________________________________________________________________________________\t"<< endl;
    cout << "\tYou have choose to perform addition,subtraction, multiplication and division operations of scalar values! :)\t"<<endl;
    cout << "\t______________________________________________________________________________________________________________\t"<< endl;

      outFile << "\n\t______________________________________________________________________________________________________________\t"<< endl;
      outFile << "\tYou have choose to perform addition,subtraction, multiplication and division operations of scalar values! :)\t"<<endl;
      outFile << "\t______________________________________________________________________________________________________________\t"<< endl;
{
    int FrstNm,
        ScndNm;
    char Operator;
    char redo;

    do
    {

    cout << "\nPlease enter your first number: "<<endl;
    cin >> FrstNm;
    cout << "\nPlease enter your operator (+,-,*,/): "<<endl;
    cin >> Operator;
    cout << "\nPlease enter your second number: "<<endl;
    cin >> ScndNm;

    outFile << "\nPlease enter your first number: "<<endl;
    outFile << FrstNm;
    outFile << "\nPlease enter your operator (+,-,*,/): "<<endl;
    outFile << Operator;
    outFile << "\nPlease enter your second number: "<<endl;
    outFile << ScndNm;


    switch(Operator)
    {

        case '+': cout << "\nThe answer is:" << tambah(FrstNm,ScndNm) << endl;
            break;
        case '-': cout << "The answer is:" << tolak(FrstNm,ScndNm) << endl;
            break;
        case '*': cout << "The answer is:" << kali(FrstNm,ScndNm) << endl;
            break;
        case '/': cout << "The answer is:" << bahagi(FrstNm,ScndNm)<< endl;
            break;
        default: cout << "Something wrong!" << endl;
            break;
    }

    cout << "\nWant to calculate anything else? (Y/N) :"<<endl;
    cin >> redo;
    outFile << "\nWant to calculate anything else? (Y/N) :"<<endl;
    outFile << redo;

    system("cls");

    } while (redo!='N' && redo!='n');


      cout<<"\nThanks! You can calculate another operation using this Engineering Calculator :)" << endl;
      cout<<endl;
      outFile<<"\nThanks! You can calculate another operation using this Engineering Calculator :)" << endl;
      outFile<<endl;
  }
}

if (choose==2)
{
        cout << "\t___________________________________________________________________________________\t"<< endl;
        cout << endl;
        cout << "\tYou have choose to perform addition, subtraction and multiplication of matrices! :)\t" << endl;
        cout << "\t___________________________________________________________________________________\t"<< endl;

        outFile << "\n\t___________________________________________________________________________________\t"<< endl;
        outFile << endl;
        outFile << "\tYou have choose to perform addition, subtraction and multiplication of matrices! :)\t" << endl;
        outFile << "\t___________________________________________________________________________________\t"<< endl;
{

     int i,j,baris,column;
     int one[10][10],
     two[10][10],
     tambah[10][10],
     tolak[10][10],
     kali[10][10];

     cout << "\nEnter the number of rows of matrix : "<<endl;
     cin >> baris;
     cout << "\nEnter the number of columns of matrix : "<<endl;
     cin >>column;

     cout << "\nEnter the elements of first matrix : "<<endl;

     outFile << "\nEnter the number of rows of matrix : "<<endl;
     outFile << baris;
     outFile << "\nEnter the number of columns of matrix : "<<endl;
     outFile <<column;

     outFile << "\nEnter the elements of first matrix : "<<endl;

     for (i=0;i<baris;i++ )
     {
     for (j=0;j<column;j++ )
     {
      cin >> one[i][j];
      outFile << one[i][j];
    }
}
   cout << "\nEnter the elements of second matrix : "<<endl;
   outFile << "\nEnter the elements of second matrix : "<<endl;

    for (i= 0 ;i< baris ;i++ )
   {
    for (j= 0;j<column;j++ )
   {
     cin >> two[i][j];
     outFile << two[i][j];
   }
}
    for (i=0;i< baris;i++ )
{
    for (j=0;j<column;j++ )
{
  tambah[i][j] = one[i][j] + two[i][j];
  tolak[i][j] = one[i][j] - two[i][j];
  kali[i][j] = one[i][j] * two[i][j];
}
}
   cout << "\nAddition of entered matrices : "<<endl;
   outFile << "\nAddition of entered matrices : "<<endl;
    for (i=0 ; i < baris ; i++ )
   {
    for ( j = 0 ; j < column ; j++ )
   {
    cout << tambah[i][j] << "\t";
    outFile << tambah[i][j] << "\t";
}
    cout << endl;
    outFile << endl;
}
    cout << "\nSubtraction of entered matrices  : "<<endl;
    outFile << "\nSubtraction of entered matrices  : "<<endl;
    for (i=0 ; i < baris ; i++ )
    {
    for ( j = 0 ; j < column ; j++ )
    {
    cout << tolak[i][j] << "\t";
    outFile << tolak[i][j] << "\t";
}
     cout << endl;
     outFile << endl;
}
    cout << "\nMultiplication of entered matrices : "<<endl;
    outFile << "\nMultiplication of entered matrices : "<<endl;
    for (i=0 ; i <baris ; i++ )
    {
    for ( j = 0 ; j < column ; j++ )
    {
    cout << kali[i][j] << "\t";
    outFile << kali[i][j] << "\t";
    }
    cout << endl;
    outFile << endl;
    }
 }
}
   if (choose==3)
{
    cout << "\t ____________________________________________________________________________________________________\t" << endl;
    cout<< endl;
    cout << "\t You have choose to perform conversion between Binary values, Hexadecimal Values and Decimal Values" << endl;
    cout << "\t ____________________________________________________________________________________________________\t" << endl;

    outFile << "\t ____________________________________________________________________________________________________\t" << endl;
    outFile<< endl;
    outFile << "\t You have choose to perform conversion between Binary values, Hexadecimal Values and Decimal Values" << endl;
    outFile << "\t ____________________________________________________________________________________________________\t" << endl;
    char redo;

    do
    {
         char convertValues,hexdecnum[100],binnum[100], hexadeci[100];
         int A,B,C,D,E,F,Q,S,R,h=1, k,n, temp,integer,arr[100],i=0,j;
         long int decnum, rem, quot,z=0,binval,hexaval=0,l=1,remainder;
	     unsigned long L,M,num=0,P;

    cout << "\t--------------------------------------------------------\t"<< endl;
    cout<<"\t\t Choose which one you want to convert: \t"<<endl;
    cout << "\t\t A - Convert decimal to binary       :\t" << endl;
    cout << "\t\t B - Convert decimal to hexadecimal  :\t" << endl;
    cout << "\t\t C - Convert binary to decimal       :\t" << endl;
    cout << "\t\t D - Convert binary to hexadecimal   :\t" << endl;
    cout << "\t\t E - Convert hexadecimal  to decimal :\t" << endl;
    cout << "\t\t F - Convert hexadecimal  to binary  :\t" << endl;
     cout << "\t--------------------------------------------------------\t"<< endl;
    cout << "You choose:";
    cin >>convertValues;

    outFile << "\t--------------------------------------------------------\t"<< endl;
    outFile<<"\t\t Choose which one you want to convert: \t"<<endl;
    outFile << "\t\t A - Convert decimal to binary       :\t" << endl;
    outFile << "\t\t B - Convert decimal to hexadecimal  :\t" << endl;
    outFile << "\t\t C - Convert binary to decimal       :\t" << endl;
    outFile << "\t\t D - Convert binary to hexadecimal   :\t" << endl;
    outFile << "\t\t E - Convert hexadecimal  to decimal :\t" << endl;
    outFile << "\t\t F - Convert hexadecimal  to binary  :\t" << endl;
     outFile << "\t--------------------------------------------------------\t"<< endl;
    outFile << "You choose:"<<endl;
    outFile <<convertValues;

    switch(convertValues)
    {
    case 'A':

    cout<<"\nEnter an integer in decimal number system : "<<endl;
    cin>> R;
    cout<<"\nIn binary number system is: "<<endl;

    outFile<<"\nEnter an integer in decimal number system : "<<endl;
    outFile<< R;
    outFile<<"\nIn binary number system is: "<<endl;

    for (Q = 3; Q >= 0; Q--)
    {
       S = R >> Q;

        if (S & 1)
        {
          cout<<"1";
          outFile<<"1";
        }

        else
        {
        cout<<"0";
         outFile<<"0";
        }

  }
    break;

    case 'B':

        cout<<"\nEnter an integer in decimal number system : "<<endl;
	    cin>>decnum;
	     outFile<<"\nEnter an integer in decimal number system : "<<endl;
	     outFile<<decnum;

	    quot=decnum;
	    while(quot!=0)
	      {
		   temp=quot%16;

		   if(temp<10){
			   temp=temp+48; }
		    else{
               temp=temp+55; }

		       hexdecnum[h++]=temp;
		       quot=quot/16; }

     	cout<<"\nIn hexadecimal value system is: "<<endl;
     	outFile<<"\nIn hexadecimal value system is: "<<endl;

	      for(k=h-1; k>0; k--) {
		    cout<<hexdecnum[k];
		      outFile<<hexdecnum[k];
		    }

        break;

    case 'C':
         cout<<"\nEnter an integer in binary number system: "<<endl;
         cin>>M;
         cout<<"\nIn decimal value system is: "<<endl;

         outFile<<"\nEnter an integer in binary number system: "<<endl;
         outFile<<M;
         outFile<<"\nIn decimal value system is: "<<endl;


        for(L=0;M!=0;++L)
          {
           P=M%10;
           num=(P)*(pow(2,L))+num;
           M=M/10;
          }
    cout<<num<<endl;
    outFile<<num<<endl;

     break;

    case 'D':

        {
            long int answer=0;
            string binval;
            cout<<"\nEnter an integer in binary number system: "<<endl;
            cin>> binval;

            outFile<<"\nEnter an integer in binary number system: "<<endl;
            outFile<< binval;

            int len=binval.size();
            for(int i=0;i<len;i++)
            {

                answer+=(binval[len-i-1]-48)*pow(2,i);
            }
        cout<<setbase(16);
        cout<<"\nIn hexadecimal value system is : "<<endl;
        cout<<answer<<endl;

         outFile<<setbase(16);
        outFile<<"\nIn hexadecimal value system is : "<<endl;
        outFile<<answer<<endl;
        }


  break;

    case 'E':

       cout<<"\nEnter a hexadecimal number system: "<<endl;
       cin >> hex >> integer;
       cout << "\nIn decimal value system is: " <<integer << endl;

        outFile<<"\nEnter a hexadecimal number system: "<< endl;
        outFile << hex;
        outFile << integer;
        outFile << "\nIn decimal value system is: " <<integer << endl;

     break;

    case 'F':

       cout<<"\nEnter a hexadecimal number system : "<<endl;
	   cin>>hexadeci;
	   cout<<"\nIn binary number system is : "<<endl;

	    outFile<<"\nEnter a hexadecimal number system : "<<endl;
	    outFile<<hexadeci;
	    outFile<<"\nIn binary number system is : "<<endl;

	     while(hexadeci[z])
	     {
		  switch(hexadeci[z])
		   {
			case '0' : cout<<"0000";
            break;
			case '1' : cout<<"0001";
			break;
			case '2' : cout<<"0010";
			break;
			case '3' : cout<<"0011";
			break;
			case '4' : cout<<"0100";
			break;
			case '5' : cout<<"0101";
			break;
			case '6' : cout<<"0110";
			break;
			case '7' : cout<<"0111";
			break;
			case '8' : cout<<"1000";
			break;
			case '9' : cout<<"1001";
			break;
			case 'A' : cout<<"1010";
			break;
			case 'B' : cout<<"1011";
			break;
			case 'C' : cout<<"1100";
			break;
			case 'D' : cout<<"1101";
			break;
			case 'E' : cout<<"1110";
			break;
			case 'F' : cout<<"1111";
			break;
			case 'a' : cout<<"1010";
			break;
			case 'b' : cout<<"1011";
			break;
			case 'c' : cout<<"1100";
			break;
			case 'd' : cout<<"1101";
			break;
			case 'e' : cout<<"1110";
			break;
			case 'f' : cout<<"1111";
			break;
            default :

            cout<<"\nInvalid hexadecimal digit "<<hexadeci[z]<<endl;
		}
	     	z++;
	}
	break;

          default:
          cout <<"\nINVALID CONVERSION"<<endl;

          outFile <<"\nINVALID CONVERSION"<<endl;

            break;
    }

    cout << endl << "\nWant to calculate anything else? (Y/N)" << endl;
    cin >> redo;

     outFile << endl << "\nWant to calculate anything else? (Y/N)" << endl;
    outFile << redo;
            system("cls");


    }
    while (redo!='N' && redo!='n');

    cout<<"\nThanks! You can calculate another operation using this Engineering Calculator :)" << endl;
    cout<<endl;
    outFile<<"\nThanks! You can calculate another operation using this Engineering Calculator :)" << endl;
    outFile<<endl;
}
if (choose==4)
{
    cout << "\t_______________________________________________________\t"<< endl;
    cout << endl;
    cout << "\tYou have choose to perform trigonometric operation! :)\t" << endl;
    cout << "\t_______________________________________________________\t"<< endl;

    outFile << "\n\t_______________________________________________________\t"<< endl;
    outFile << endl;
    outFile << "\tYou have choose to perform trigonometric operation! :)\t" << endl;
    outFile << "\t_______________________________________________________\t"<< endl;
{
    double sine,cosine,tangent,cotangent,cosecant,secant;
    double sudut;
    char a;

    do
    {
     cout << endl << "Please enter the angle: "<<endl;
    cin >> sudut;

    outFile << endl << "Please enter the angle: "<<endl;
    outFile << sudut;

    sine=sin(sudut*(pi/180));
    cosine = cos(sudut*(pi/180));
    tangent = tan(sudut*(pi/180));
    cotangent = 1/tan(sudut*(pi/180));
    cosecant = 1/sin(sudut*(pi/180));
    secant = 1/cos(sudut*(pi/180));

    cout << "\nThe value for sine is: " << sine << endl;
    cout << "\nThe value for cosine is: " << cosine << endl;
    cout << "\nThe value for tangent is: " << tangent << endl;
    cout << "\nThe value for cotangent is: " << cotangent << endl;
    cout << "\nThe value for cosecant is: " << cosecant << endl;
    cout << "\nThe value for secant is: " << secant << endl;

    outFile << "\nThe value for sine is: " << sine << endl;
    outFile << "\nThe value for cosine is: " << cosine << endl;
    outFile << "\nThe value for tangent is: " << tangent << endl;
    outFile << "\nThe value for cotangent is: " << cotangent << endl;
    outFile << "\nThe value for cosecant is: " << cosecant << endl;
    outFile << "\nThe value for secant is: " << secant << endl;



    cout << "\nDo you want to calculate using another angle?\t"<<endl;
    cout << "\nRun again? (Y/N): " << endl ;
    cin>>a;
    cout << endl;

    outFile << "\nDo you want to calculate using another angle?\t"<<endl;
    outFile << "Run again? (Y/N): " << endl ;
    outFile<<a;
    outFile << endl;

    system("cls");



    }while (a!='N' && a!='n');

    cout<<"Thanks" << endl;

     outFile<<"Thanks" << endl;
  }

}
if (choose==5)
{
    char redo;
            system("cls");

    do
    {
    cout<<endl;
    cout << "\t ________________________________________________________________________________________ \t" << endl;
    cout << endl;
    cout << "\t You have choose to perform electrical Charge, Capacitance, Current, Voltages and Power \t" << endl;
    cout << "\t ________________________________________________________________________________________\t" << endl;

    outFile<<endl;
    outFile << "\t ________________________________________________________________________________________ \t" << endl;
    outFile << endl;
    outFile << "\t You have choose to perform electrical Charge, Capacitance, Current, Voltages and Power \t" << endl;
    outFile << "\t ________________________________________________________________________________________\t" << endl;

    {
    char electrical_charge;
     float I,
           R,
           V,
           P,
           C,
           Q;

    cout << "\nI for current     " << endl;
    cout << "V for voltage     " << endl;
    cout << "P for power       " << endl;
    cout << "C for capacitance " << endl;

    cout << "\nChoose the electrical charge: ";
    cin >>electrical_charge;

    outFile << "I for current     " << endl;
    outFile << "V for voltage     " << endl;
    outFile << "P for power       " << endl;
    outFile << "C for capacitance " << endl;

    outFile << "\nChoose the electrical charge: "<<endl;
    outFile <<electrical_charge;

    switch(electrical_charge)
    {
        case 'I':

    cout<< "\nEnter the value of voltage,V = "<<endl;
    cin >> V;

    cout<< "\nEnter the value of Resistance,R = "<<endl;
    cin >> R;

     outFile<< "\nEnter the value of voltage,V = "<<endl;
    outFile << V;

    outFile<< "\nEnter the value of Resistance,R = "<<endl;
    outFile << R;


    I=V/R;

    cout << setprecision(2) << fixed;
    cout << "\nThe value of current is:" << " I = " << I <<endl;

     outFile << setprecision(2) << fixed;
    outFile << "\nThe value of current is:" << " I = " << I <<endl;

    break;

    case 'V':

    cout<< "\nEnter the value of current,I = "<<endl;
    cin >> I;

    cout<< "\nEnter the value of Resistance,R = "<<endl;
    cin >> R;

     outFile<< "\nEnter the value of current,I = "<<endl;
    outFile << I;

    outFile<< "\nEnter the value of Resistance,R = "<<endl;
    outFile << R;

    V=I*R;

    cout << setprecision(2) << fixed;
    cout << "\nThe value of voltage is:" << " V = " << V <<endl;

    outFile << setprecision(2) << fixed;
    outFile << "\nThe value of voltage is:" << " V = " << V <<endl;

    break;

    case 'P':   cout<< "\nEnter the value of current,I = "<<endl;
                cin >> I;

                cout<< "\nEnter the value of voltage is,V = "<<endl;
                cin >> V;

                outFile<< "\nEnter the value of current,I = "<<endl;
                outFile << I;

                outFile<< "\nEnter the value of voltage is,V = "<<endl;
                outFile << V;


                P=I*V;

                cout << setprecision(2) << fixed;
                cout << "\nThe value of power is:" << " P = " << P <<endl;

                 outFile << setprecision(2) << fixed;
                outFile << "\nThe value of power is:" << " P = " << P <<endl;

                break;

    case 'C':   cout<< "\nEnter the value of charge,Q = "<<endl;
                cin >> Q;

                cout<< "\nEnter the value of voltage is,V = "<<endl;
                cin >> V;

                outFile<< "\nEnter the value of charge,Q = "<<endl;
                outFile << Q;

                outFile<< "\nEnter the value of voltage is,V = "<<endl;
                outFile << V;

                C=Q/V;

                cout << setprecision(2) << fixed;
                cout <<"\nThe value of capacitance is" << "C = " << C <<endl;

                 outFile << setprecision(2) << fixed;
                 outFile <<"\nThe value of capacitance is" << "C = " << C <<endl;

                break;

                default:

                cout <<"\nError! ELECTRICAL CHARGE DOES NOT EXIST"<<endl;

                outFile <<"\nError! ELECTRICAL CHARGE DOES NOT EXIST"<<endl;


                break;
    }
}
    cout << "\nWant to calculate anything else? (Y/N)";
    cin >> redo;
    cout<<endl;
    outFile << "\nWant to calculate anything else? (Y/N)";
    outFile<<endl;
     outFile << redo;

            system("cls");


    }
    while (redo!='N' && redo!='n');

    cout<<"\nThanks! You can calculate another operation using this Engineering Calculator :)" << endl;
    outFile<<"\nThanks! You can calculate another operation using this Engineering Calculator :)" << endl;

}
if (choose==6)
{

    cout<<endl;
    cout << "\t __________________________________________________________________________________________________\t " << endl;
    cout << endl;
    cout << "\t You have choose to perform Perimeter/Circumference, Area and Volume of rectangles and circles! :) \t" << endl;
    cout << "\t __________________________________________________________________________________________________\t " << endl;


    outFile <<endl;
    outFile << "\t __________________________________________________________________________________________________\t " << endl;
    outFile << endl;
    outFile << "\t You have choose to perform Perimeter/Circumference, Area and Volume of rectangles and circles! :) \t" << endl;
    outFile << "\t __________________________________________________________________________________________________\t " << endl;
    {


    object Rectangle;
    object Circle;

    cout<< endl << "This program will compute the perimeter/circumference,";
    cout<<"area and volume of rectangle and circle."<<endl;

    outFile<< endl << "This program will compute the perimeter/circumference,";
    outFile<<"area and volume of rectangle and circle."<<endl;

   const double PI=3.142;

   Rectangle;
   Circle;

   cout<< endl << "\n\t\t(1)RECTANGLE\t\t"<<endl;

   cout << endl << "Enter the length of a rectangle: ";
   cin >> Rectangle.panjang;

   cout << "Enter the width of a rectangle: ";
   cin >> Rectangle.lebar;

   cout << "Enter the height of a rectangle: ";
   cin >> Rectangle.tinggi;

   cout << endl << endl;


   outFile<< endl << "\n\t\t(1)RECTANGLE\t\t"<<endl;

   outFile << endl << "Enter the length of a rectangle: ";
   outFile << Rectangle.panjang;

   outFile << "Enter the width of a rectangle: ";
   outFile << Rectangle.lebar;

   outFile << "Enter the height of a rectangle: ";
   outFile << Rectangle.tinggi;

   outFile << endl << endl;

   Rectangle.perimeter = 2 * Rectangle.panjang + 2 * Rectangle.lebar;
   Rectangle.luas = Rectangle.panjang * Rectangle.lebar;
   Rectangle.isipadu = Rectangle.panjang * Rectangle.lebar * Rectangle.tinggi;


   cout << fixed << showpoint << setprecision(2);

   cout << "The perimeter of the rectangle is " << Rectangle.perimeter << endl;
   cout << "The area of the rectangle is " << Rectangle.luas << endl;
   cout << "The volume of the rectangle is " << Rectangle.isipadu << endl;

   cout<<"\n\n\t\t(2)CIRCLE\t\t"<<endl;

   cout <<endl << "Enter the radius of a circle: ";
   cin >> Circle.radius;

   cout << endl << endl;

    outFile << fixed << showpoint << setprecision(2);

   outFile << "The perimeter of the rectangle is " << Rectangle.perimeter << endl;
   outFile << "The area of the rectangle is " << Rectangle.luas << endl;
   outFile << "The volume of the rectangle is " << Rectangle.isipadu << endl;

   outFile<<"\n\n\t\t(2)CIRCLE\t\t"<<endl;

   outFile <<endl << "Enter the radius of a circle: ";
   outFile << Circle.radius;

   outFile << endl << endl;

   Circle.circumference = 2 * PI * Circle.radius;
   Circle.luas = PI *pow(Circle.radius,2) ;
   Circle.isipadu = (4 * PI * pow(Circle.radius,3))/3;

   cout << fixed << showpoint << setprecision(2);

   cout << "The perimeter of the circle is :" << Circle.circumference << endl;
   cout << "The area of the circle is :"<< Circle.luas << endl;
   cout << "The volume of the circle is :"<< Circle.isipadu << endl;

   outFile << fixed << showpoint << setprecision(2);

   outFile << "The perimeter of the circle is :" << Circle.circumference << endl;
   outFile << "The area of the circle is :"<< Circle.luas << endl;
   outFile << "The volume of the circle is :"<< Circle.isipadu << endl;
    }
    }

if (choose==7)
{
    cout << "\n\t _____________________________________________________________\t " << endl;
    cout << endl;
    cout << "\t You have choose to perform roots of quadratic equation! :) \t"<< endl;
    cout << "\t _____________________________________________________________\t " << endl;

    outFile << "\n\t _____________________________________________________________\t " << endl;
    outFile << endl;
    outFile << "\t You have choose to perform roots of quadratic equation! :) \t"<< endl;
    outFile << "\t _____________________________________________________________\t " << endl;
{


 int a,b,c,value;

    cout<< endl << "Please enter the value of a,b and c :"<<endl;

    cout<< "\na:"<<endl;
    cin>>a;
    cout << "\nb:"<<endl;
    cin >>b;
    cout<< "\nc:"<<endl;
    cin>>c;
    cout<<"\nYour quadratic function is :" << " " ;
    cout<< "(" << a << "x^2+" << b << "x+" << c << ")" << endl;

    cout<<"\nComputing root...."<<endl;

    outFile<< endl << "Please enter the value of a,b and c :"<<endl;

    outFile<< "\na:"<<endl;
    outFile<<a;
    outFile << "\nb:"<<endl;
    outFile <<b;
    outFile<< "\nc:"<<endl;
    outFile<<c;
    outFile<<"\nYour quadratic function is :" << " " ;
    outFile<< "(" << a << "x^2+" << b << "x+" << c << ")" << endl;

    outFile<<"\nComputing root...."<<endl;

  computeQuad(a,b,c);
   if(value>0)
       outFile<<"\nThere is two real root."<<endl;

     if(value==0)
         outFile<<"\nThere is one real root."<<endl;

    if(value<0)
         outFile<<"\nThere is no real root."<<endl;



}
}
if (choose==8){
    int teruskan;
    AAFile.open("alianis.txt");
    teruskan:cout<<" "<<endl;
    while(getline(AAFile,sejarah))
     cout<<sejarah<<endl;

     AAFile.close();

        cout<<"Press 1 to continue and 2 to exit from history\n"<<endl;
        cin>>teruskan;
        system("cls");
        if(teruskan==1){
            goto gomenu;
        }
        else if(teruskan==2){
            cout<<"Exit from your history :)"<<endl;
        }
        else
        {
            cout<<"Invalid"<<endl;
            goto teruskan;
        }

}
cout << endl;
cout << "\nDo you want to perform another calculation?"<<endl;
        cout << "Run again? Y/N: " ;
        cin>>redo;
            system("cls");

            outFile << endl;
        outFile << "\nDo you want to perform another calculation?"<<endl;
        outFile << "Run again? Y/N: " ;
        outFile<<redo;
            system("cls");

 }while ( redo!='N' && redo!='n');
//system("cls");
    cout<<"\nThank you for using this Engineering Calculator! :)" << endl;

     outFile<<"\nThank you for using this Engineering Calculator! :)" << endl;


  outFile.close();


}

void displayMenu()
{


cout << "\n\t\t------------------------------------------------------------------------------\t\t" << endl;
cout <<   "\t\tTHIS "; Sleep(200);
cout <<   " PROGRAM "; Sleep(200);
cout <<   " WILL "; Sleep(200);
cout <<   " DEVELOP "; Sleep(200);
cout <<   " AN "; Sleep(200);
cout <<   " ENGINEERING "; Sleep(200);
cout <<   " CALCULATOR "; Sleep(200);
cout <<   " WITH "; Sleep(200);
cout <<   " 7 "; Sleep(200);
cout <<   " OPERATIONS "<<endl;

cout << "\n\t\t------------------------------------------------------------------------------\t\t" << endl;
cout << endl;
cout << " \t\tPLEASE CHOOSE THE OPERATION THAT YOU WANT TO USE:\t\t"<< endl;
cout << "\n\t\t1. Addition,subtraction, multiplication and division operations of scalar values\t\t" << endl;
cout << "\t\t2. Addition, subtraction and multiplication of matrices\t\t" << endl;
cout << "\t\t3. Conversion between Binary values, Hexadecimal Values and Decimal Values\t\t " << endl;
cout << " \t\t4. Trigonometric operation\t\t" << endl;
cout << " \t\t5. Electrical Charge, Capacitance, Current, Voltages and Power\t\t " << endl;
cout << " \t\t6. Perimeter/Circumference, Area and Volume of rectangles and circles\t\t "<< endl;
cout << " \t\t7. Roots of quadratic equation\t\t" << endl;
cout << " \t\t8. History\t\t" << endl;


}
void computeQuad(int &a,int &b,int &c)
 {
 double value=(b*b)-(4*a*c);

      if(value>0)
      {
         cout<<"\nThere is two real root."<<endl;

         double equation1=(-b+pow(value,0.5))/(2*a);
         double equation2=(-b-pow(value,0.5))/(2*a);

         cout<<"The root is:"<< " " << equation1 << " " << "and" << " " << equation2 <<endl;

         //outFile<<"The root is:"<< " " << equation1 << " " << "and" << " " << equation2 <<endl;
      }

      if(value==0)
      {
         cout<<"\nThere is one real root."<<endl;

         double equation1=(-b+pow(value,0.5))/(2*a);

         cout<<"The root is:"<< " " << equation1 << endl;

      }

      if(value<0)
      {
         cout<<"\nThere is no real root."<<endl;

   }
 }
    int tambah(int A,int B)
    {
        return A+B;
    }
    int tolak(int A,int B)
    {
        return A-B;
    }
    int kali (int A,int B)
    {
        return A*B;
    }
    int bahagi (int A,int B)
    {
        return A/B;
    }





# data[].attributes.body
Mini Project Coding

# data[].attributes.attachment_link.readable_text
#include    <iostream>
#include    <iomanip>
#include 	<cmath>
#include    <fstream>
using namespace std;

ofstream EngineCalc("Engineering Calculator.txt");

char choose,convert,choice,choices;
unsigned long convtodecinum(char hexa[]);

float PI = 3.14159265;


float AreaRec (float,float);
float Perimeter (float,float);
float VolumeA(float,float,float);
double AreaCir (float);
double Circumference (float);
int VolumeB(float);


void P1();
void P2();
void P3();
void P4();
void P5();
void P6();

struct calc
{
    string name;
    string oprt;
};
int main()
{
    calc one= {"Basic Operation","+, -, *, /"};
    calc two= {"Matrices","| |"};
    calc three= {"Base","Binary, Decimal, Hexadecimal"};
    calc four= {"Trigonometric","sin, cos, tan"};
    calc five= {"Basic Engineering Operation,","V, I, C, P"};
    calc six= {"Circumference, Perimeter, Area, Volume","m, m^2, m^3"};
    calc seven= {"Root of Quadratic Equations","real, imaginary"};

	mainhome:

    cout<<endl<<endl;
    cout << "               Dragon Presasi's Engineering Calculator" << endl;
    cout << "   =============================================================" <<endl;
    cout << "  |              CHOOSE ANY CALCULATIONS YOU WANT               |" <<endl;
    cout << "  |1. "<<one.name<<" ("<<one.oprt<<")"<<"                              |" <<endl;
    cout << "  |2. " <<two.name<<" ("<<two.oprt<<")"<<"                                            |" <<endl;
    cout << "  |3. " <<three.name<<" ("<<three.oprt<<")"<<"                       |" <<endl;
    cout << "  |4. " <<four.name<<" ("<<four.oprt<<")"<<"                             |" <<endl;
    cout << "  |5. " <<five.name<<" ("<<five.oprt<<")"<<"                 |" <<endl;
    cout << "  |6. " <<six.name<<" ("<<six.oprt<<")"<<"      |" <<endl;
    cout << "  |7. " <<seven.name<<" ("<<seven.oprt<<")"<<"             |" <<endl;
    cout << "   =============================================================" <<endl;

	cin >> choose;


	switch(choose)
	{
		case'1':
        cout<<endl;
		cout<<"Addition (+) (press 1)"<<endl;
		cout<<"Subtraction (-) (press 2)"<<endl;
		cout<<"Multiplication (*) (press 3)"<<endl;
		cout<<"Division (/) (press 4)"<<endl<<endl;
		cin>>choose;
		P1();
		cout<<endl;
		goto mainhome;


		case'2':
        cout<<endl;
		cout<<"Addition (press 1)"<<endl;
        cout<<"Subtraction (press 2)"<<endl;
        cout<<"Multiplication (press 3)"<<endl;
        cout<<"Division (/) (press 4)"<<endl<<endl;
        cin>>(choose);
		P2();
		cout<<endl;
		goto mainhome;


		case'3':
        cout<<endl;
		cout << "Decimal to Binary (press 1)" << endl;
    	cout << "Decimal to Hexadecimal (press 2)" << endl;
    	cout << "Binary to Decimal (press 3)" << endl;
    	cout << "Binary to Hexadecimal (press 4)" << endl;
    	cout << "Hexadecimal to Decimal (press 5)" << endl;
    	cout << "Hexadecimal to Binary (press 6)" << endl;
    	cout <<"Choose one that want to convert: "<<endl;
    	cin  >>convert;
		P3();
		cout<<endl;
		goto mainhome;


		case'4':
        cout<<endl;
		cout<< "Choose any of these trigonometry : " << endl;
    	cout<< "cos (select a)" <<endl;
    	cout<< "sin (select b)" <<endl;
    	cout<< "tan (select c)" <<endl;
    	cout<< "cosec (select d)" <<endl;
    	cout<< "sec (select e)" <<endl;
    	cout<< "cot (select f)" <<endl<<endl;
    	cin>>choice;
    	P4();
		cout<<endl;
		goto mainhome;


		case'5':
        cout<<endl;
		cout<<"Voltage (press v)"<<endl;
		cout<<"Current (press i)"<<endl;
    	cout<<"Power (press p)"<<endl;
		cout<<"capacitance (press c)"<<endl;
    	cout<<"Choose one of the components to solve for: ";
    	cin >> choices;
    	P5();
		cout<<endl;
    	goto mainhome;


    	case'6':
    	float l,w,h,r;
        cout<<endl;
    	cout << "Rectangle"<<endl;
    	cout << "Insert your length (cm)"<<endl;
    	cin  >> l;
    	cout << "Insert your width (cm)"<<endl;
    	cin  >> w;
    	cout << "Insert your height (cm)"<<endl;
    	cin  >> h;
    	cout << "The area of the rectangle is " << AreaRec(l,w) << "cm^2, the perimeter is " << Perimeter(l,w)
         	 << "cm and the volume is " << VolumeA(l,w,h) << "cm^3" << endl;
        EngineCalc<<"The perimeter is = "<<Perimeter(l,w) <<" ,the area is = "<<AreaRec(l,w)<<" and the volume is = "<<VolumeA(l,w,h)<<endl;
    	cout << endl;

    	cout << "Circle" << endl;
    	cout << "Insert radius of the circle (cm): \n";
    	cin  >> r;
    	cout  << fixed << setprecision(2);
    	cout << "The area of your circle is " << AreaCir(r) << "cm^2 and the circumference is "
             << Circumference(r) << "cm" << " and the volume is "<< VolumeB(r)<<endl;
        EngineCalc<<"The circumference is = "<<Circumference(r) <<" ,the area is = "<<AreaCir(r)<<" and the volume is = "<<VolumeB(r)<<endl;
    	cout <<endl;
		goto mainhome;


		case'7':
		P6();
		cout<<endl;
		goto mainhome;


		default :
        cout<<endl;
        cout<<endl;
		cout<< "Error" <<endl;
		cout<<endl;
		goto mainhome;
	}

	return 0;

}


void P1()
	{
	float a, b, result;

		switch(choose)
		{
			case '1' :
                cout<<endl;
			    cout<<"Enter two number : ";
				cin>>a>>b;
				result=a+b;
				cout<<endl<<"Result = "<<result;
				EngineCalc<<"Result for addition = "<<result<<endl;
				break;
			case '2' :
                cout<<endl;
			    cout<<"Enter two number : ";
				cin>>a>>b;
				result=a-b;
				cout<<endl<<"Result = "<<result;
				EngineCalc<<"Result for subtraction = "<<result<<endl;
				break;
			case '3' :
                cout<<endl;
                cout<<"Enter two number : ";
				cin>>a>>b;
				result=a*b;
				cout<<endl<<"Result = "<<result;
				EngineCalc<<"Result for multiplication = "<<result<<endl;
				break;
			case '4' :
                cout<<endl;
			    cout<<endl<<"Enter two number : ";
				cin>>a>>b;
				result=a/b;
				cout<<endl<<"Result = "<<result;
				EngineCalc<<"Result for division = "<<result<<endl;
				break;
		}
	}


void P2()
{
	int mat1[2][2], mat2[2][2], i, j, mat3[2][2];
	switch(choose)
	{
	    case'1':
        cout<<endl;
	    cout<< "Please enter first matrix elements :";
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cin>>mat1[i][j];
		}
	}
	cout<< "Please enter second matrix elements :";
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cin>>mat2[i][j];
		}
	}
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			mat3[i][j]=mat1[i][j]+mat2[i][j];
		}
	}
	cout<< "The answer of two matrices are :" <<endl;
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cout<<mat3[i][j]<<" ";
			EngineCalc<<"The addition of two matrices is "<<mat3[i][j]<<endl;
		}
		cout<<endl;
	}break;

    case'2':
    cout<<endl;
	cout<<"Enter matrix 1 elements :";
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cin>>mat1[i][j];
		}
	}
	cout<<"Enter matrix 2 elements :";
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cin>>mat2[i][j];
		}
	}
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			mat3[i][j]=mat1[i][j]-mat2[i][j];
		}
	}
	cout<<"The subtraction of two matrices is :"<<endl;
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cout<<mat3[i][j]<<" ";
			EngineCalc<<"The subtraction of two matrices is "<<mat3[i][j]<<endl;
		}
		cout<<endl;
	}break;

	case'3':
        cout<<endl;
	    cout<<"Enter matrix 1 elements :";
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cin>>mat1[i][j];
		}
	}
	cout<<"Enter matrix 2 elements :";
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cin>>mat2[i][j];
		}
	}
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			mat3[i][j]=mat1[i][j]*mat2[i][j];
		}
	}
	cout<<"The multiplication of two matrices is :"<<endl;
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			cout<<mat3[i][j]<<" ";
			EngineCalc<<"The multiplication of two matrices is "<<mat3[i][j]<<endl;
		}
		cout<<endl;
	}break;}

}


void P3()
{
		char choose,hexdec[100],bin[100], hexadeci[100];
         int A,B,C,h=1, k,n, temp,integer,arr[100],i=0,j;
         long int decnum, rem, quot,z=0,binval,hexaval=0,l=1,remainder;
	     unsigned long L,M,num=0,P;
		switch(convert)
    {
    case '1':
        cout<<endl;
        cout<< "Please key in Dec num : ";
        cin>> C;
        cout<<endl;
        cout<< "Bin num is: ";

    for (A = 3; A >= 0; A--)
    {
       B = C >> A;
        if (B & 1)
         cout<<"1";
        else
         cout<<"0";
    }
    break;

    case '2':
        cout<<endl;
        cout<< "Please key in Dec num : ";
	    cin>>decnum;
	    quot=decnum;
	    while(quot!=0)
	      {
		   temp=quot%16;
		   if(temp<10){
			   temp=temp+48; }
		    else{
               temp=temp+55; }

		       hexdec[h++]=temp;
		       quot=quot/16; }
        cout<<endl;
     	cout<< "Hexa num is "<<decnum<< " is ";
	      for(k=h-1; k>0; k--) {
		    cout<<hexdec[k];}
		    EngineCalc<<"The hexadecimal number is : "<<hexdec[k]<<endl;

        break;

    case '3':
         cout<<endl;
         cout<< "Please key in Bin num : ";
         cin>>M;
         cout<<endl;
         cout<< "Dec num is: "<<M<<endl;

        for(L=0;M!=0;++L)
          {
           P=M%10;
           num=(P)*(pow(2,L))+num;
           M=M/10;
          }
    cout<<num;
    EngineCalc<<"Bin - Dec ="<<num<<endl;

     break;

    case '4':
        cout<<endl;
        cout<< "Please key in Bin num : ";
        cin>> binval;

   while (binval !=0)
   {
     remainder = binval % 10;
     hexaval = hexaval + remainder*l;
     l=l*2;

     binval=binval/10;
   }

        cout<<endl;
        cout<< "Hexa num is : "<<hexaval<<endl;
        EngineCalc<<"Bin - Hex = "<<hexaval<<endl;

  break;

    case '5':
       cout<<endl;
       cout<< "Please key in Hexa num : "<<endl;
       cin >> hex >> integer;
       cout<<endl;
       cout << "Dec num is: " <<integer <<endl;
       EngineCalc<<"Hex - Dec = "<<integer<<endl;


     break;

    case '6':
       cout<<endl;
       cout<< "Please key in Hexa num : ";
	   cin>>hexadeci;
       cout<<endl;
	   cout<< "Bin num is : ";
	     while(hexadeci[z])
	     {
		  switch(hexadeci[z])
		   {
			case '0' : cout<<"0000"; break;
			EngineCalc<<"0000";
			case '1' : cout<<"0001"; break;
			EngineCalc<<"0001";break;
			case '2' : cout<<"0010"; break;
			EngineCalc<<"0010";break;
			case '3' : cout<<"0011"; break;
			EngineCalc<<"0011";break;
			case '4' : cout<<"0100"; break;
			EngineCalc<<"0100";break;
			case '5' : cout<<"0101"; break;
			EngineCalc<<"0101";break;
			case '6' : cout<<"0110"; break;
			EngineCalc<<"0110";break;
			case '7' : cout<<"0111"; break;
			EngineCalc<<"0111";break;
			case '8' : cout<<"1000"; break;
			EngineCalc<<"1000";break;
			case '9' : cout<<"1001"; break;
			EngineCalc<<"1001";break;
			case 'A' : cout<<"1010"; break;
			EngineCalc<<"1010";break;
			case 'B' : cout<<"1011"; break;
			EngineCalc<<"1011";break;
			case 'C' : cout<<"1100"; break;
			EngineCalc<<"1100";break;
			case 'D' : cout<<"1101"; break;
			EngineCalc<<"1101";break;
			case 'E' : cout<<"1110"; break;
			EngineCalc<<"1110";break;
			case 'F' : cout<<"1111"; break;
			EngineCalc<<"1111";break;
			case 'a' : cout<<"1010"; break;
			EngineCalc<<"1010";break;
			case 'b' : cout<<"1011"; break;
			EngineCalc<<"1011";break;
			case 'c' : cout<<"1100"; break;
			EngineCalc<<"1100";break;
			case 'd' : cout<<"1101"; break;
			EngineCalc<<"1101";break;
			case 'e' : cout<<"1110"; break;
			EngineCalc<<"1110";break;
			case 'f' : cout<<"1111"; break;
			EngineCalc<<"1111";break;
            default : cout<<" Invalid "<<hexadeci[z];
            EngineCalc<<" Invalid "<<hexadeci[z];
		}
	     	z++;
	}
	break;
          default:
          cout<<endl;
          cout <<"Error"<<endl;

            break;
   }

}


void P4()
{
	float degree;
	switch (choice)
	{
			case 'a':
            cout<<endl;
    		cout << "Enter value of angle : ";
    		cin >> degree;
            cout<<endl;
    		cout << "The trigonometric for :" << endl;
    		cout << "cos = "<<cos (degree*(PI/180)) << endl;
    		EngineCalc<<"The trigo number is: "<<cos (degree*(PI/180))<<endl;
    		break;

			case'b':
            cout<<endl;
			cout << "Enter value of angle : ";
    		cin >> degree;
            cout<<endl;
    		cout << "sin = "<<sin (degree*(PI/180)) << endl;
    		EngineCalc<<"The trigo number is: "<<sin (degree*(PI/180))<<endl;
    		break;

			case'c':
            cout<<endl;
   			cout << "Enter value of angle : ";
    		cin >> degree;
            cout<<endl;
    		cout << "tan = "<<tan (degree*(PI/180)) << endl;
    		EngineCalc<<"The trigo number is: "<<tan (degree*(PI/180))<<endl;
    		break;

    		case'd':
            cout<<endl;
    		cout << "Enter value of angle : ";
    		cin >> degree;
            cout<<endl;
    		cout << "cosec = "<<1/cos (degree*(PI/180)) << endl;
    		EngineCalc<<"The trigo number is: "<<1/cos (degree*(PI/180))<<endl;
    		break;

    		case'e':
            cout<<endl;
    		cout << "Enter value of angle : ";
    		cin >> degree;
            cout<<endl;
    		cout << "sec = "<<1/sin (degree*(PI/180)) << endl;
    		EngineCalc<<"The trigo number is: "<<1/sin (degree*(PI/180))<<endl;
    		break;

    		case'f':
            cout<<endl;
    		cout << "Enter value of angle : ";
    		cin >> degree;
            cout<<endl;
    		cout << "cot = "<<1/tan (degree*(PI/180)) << endl;
    		EngineCalc<<"The trigo number is: "<<1/tan (degree*(PI/180))<<endl;
			break;
	}

}


void P5()
{
	float Q,V,R,I,P,C;
	if(choices == 'v')
    {
    cout<<endl;
    cout <<"Your formula is (V=IR)"<<endl;
    cout <<"Please enter a value of Resistance (R): ";
    cin  >> R;
    cout<<endl;
    cout <<"Please enter a value of Current(I): ";
    cin  >> I;
    cout<<endl;
    cout <<"The value of Voltage (V) = "<< R * I <<endl<<endl;
    EngineCalc<<"The value of Voltage (V) = "<< R * I <<endl;
    }
if(choices == 'i')
    {
    cout <<"Your formula is (I=V/R)"<<endl;
    cout <<"Please enter a value of Voltage (V): ";
    cin  >> V;
    cout <<"Please enter a value of Resistance (R): ";
    cin  >> R;
    cout <<"The value of Current (I) = "<< V / R <<endl<<endl;
    EngineCalc<<"The value of Current (I) = "<< V / R <<endl;
    }
if(choices == 'p')
    {
    cout <<"Your formula is (P=I*I*R)"<<endl;
    cout <<"Please enter a value of Current (I): ";
    cin  >> I;
    cout <<"Please enter a value of Resistance (R): ";
    cin  >> R;
    cout <<"The value of Power = "<< pow(I,2) * R<<endl<<endl;
    EngineCalc<<"The value of Power = "<< pow(I,2) * R<<endl;

    }
if(choices == 'c')
    {
    cout <<"Your formula is (Q/V)"<<endl;
    cout <<"Please enter a value of Charge (Q): ";
    cin  >> Q;
    cout <<"Please enter a value of Voltage (V): ";
    cin  >> V;
    cout <<"The value of capacitance = "<< Q/V <<endl<<endl;
    EngineCalc<<"The value of capacitance = "<< Q/V <<endl;
    }

}


void P6()
{
	float a, b, c,d, x1, x2, real, imaginary;
    cout << "Enter coefficients a, b and c: ";
    cin >> a >> b >> c;
    cout<<endl;
     d = b*b - 4*a*c;

    if (d > 0)
    {
        x1 = (-b + sqrt(d)) / (2*a);
        x2 = (-b - sqrt(d)) / (2*a);
        cout << "Roots are real and different." << endl;
        cout << "x1 = " << x1 << endl;
        cout << "x2 = " << x2 << endl;
        EngineCalc<<"The value of x1 and x2 are = "<< x1<<" "<<x2<<endl;
    }

    else if (d == 0)
    {
        cout << "Roots are real and same." << endl;
        x1 = (-b + sqrt(d)) / (2*a);
        cout << "x1 = x2 =" << x1 << endl;
        EngineCalc<<"The value of x1 and x2 are = "<< x1<<" "<<x2<<endl;
    }

    else {
        real = -b/(2*a);
        imaginary =sqrt(-d)/(2*a);
        cout << "Roots are complex and different."  << endl;
        cout << "x1 = " << real << "+" << imaginary << "i" << endl;
        cout << "x2 = " << real << "-" << imaginary << "i" << endl;
        EngineCalc<<"The value of x1 and x2 are = "<< x1<<" "<<x2<<endl;
    }

}


float AreaRec(float l,float w)
		{
    		return l*w;
		}

		float Perimeter(float l,float w)
		{
    		return (l+w+l+w);
		}

		float VolumeA(float l,float w, float h)
		{
    		return l*w*h;
		}

		double AreaCir(float r)
		{
    		return PI*pow(r,2);
		}

		double Circumference(float r)
		{
    		return 2*PI*r;
		}
			int VolumeB(float r)
		{
    		return (4/3)*(PI*(pow(r,3)));
		}


# data[].attributes.body
MINI PROJECT REPORT

# data[].attributes.body
PROJECTX
MUHAMAD HANNIF
SITI DIANA
IZZAT SHAFIQ

# data[].attributes.body
PROJECTX
IZZAT SHAFIQ
SITI DIANA
MUHAMAD HANNIF

# data[].attributes.attachment_link.title
FULL REPORT ECE431 MINIPROJECT (PROJECTX)

# data[].attributes.body
GROUP : JEBAT
1. RABIATUL 'ADAWIAH
2. NUR SABRINA

# data[].attributes.body
GROUP : JEBAT
1. RABIATUL 'ADAWIAH
2. NUR SABRINA

# data[].attributes.body
Mini Project (report)

# data[].attributes.body
Mini Project(coding)

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <fstream>
#include <iomanip>

#define MAX 1000
using namespace std;
const double PI = 3.142;
struct Rect
{
double length,width,height,perimeter,area,volume;
};
struct Circ
{
double radius,circumference,area,volume;
};
void Values(float&,float&);
void addNumber(float,float,float*);
void subNumber(float,float,float*);
void multiNumber(float,float,float*);
void dividNumber(float,float,float*);
int convDecToBin(int);
void deg(float&);
void volt(float&);
void curr(float&);
void resistance (float&);
void computeVol(float,float,float*);
void computeCur(float,float,float*);
void elecCharge (float,float*);
void capa(float, float, float*);
void powe(float, float, float*);
void quadraticAnswer(float,float,float);

int main()
{
    int num;
    cout<<"\t\t\tThis is an engineering calculator" << endl;
    cout<<"\t\t\t*********************************" << endl;
    cout<<"\t\t\tPLEASE ENTER YOUR DESIRED OPERATION"<< endl<<endl<<endl;
    cout<<"1. Addition, subtraction, multiplication and division operations of scalar\n"
        <<"   values."<<endl<<endl;
    cout<<"2. Addition, subtraction and multiplication of matrices."<<endl<<endl;
    cout<<"3. Conversion between Binary values, Hexadecimal Values and Decimal Values."<<endl<<endl;
    cout<<"4. Trigonometric operations such as finding cosine, sine, tangent, cotangent,\n"
        <<"   cosecant and secant."<<endl<<endl;
    cout<<"5. Compute Electrical Charge, Capacitance, Current, Voltages and Power, given\n"
        <<"   that required parameters are given by user."<<endl<<endl;
    cout<<"6. Compute Perimeter/Circumference, Area and Volume of rectangles and circles,\n"
        <<"   given that required parameters are given by user."<<endl<<endl;
    cout<<"7. Solve roots of quadratic equations."<<endl<<endl;
    cout<<"Your choice: ";
    cin>>num;
    switch(num)
    {
        case 1:
        {
        ofstream outFile;
        outFile.open("MathOperation.txt",fstream::app);
        int op;
        float ans1,ans2,ans3,ans4,number1,number2;
        cout<<"Please choose operation 1 for addition!"<<endl;
        cout<<"Please choose operation 2 for subtraction!"<<endl;
        cout<<"Please choose operation 3 for multiplication!"<<endl;
        cout<<"Please choose operation 4 for divide!"<<endl;
        cout << "Enter operator either 1 or 2 or 3 or 4: ";
        cin >> op;
        Values(number1,number2);
        switch(op)
        {
        case 1:
            addNumber(number1,number2,&ans1);
            cout<<"Your answer is :"<< ans1<<endl;
            outFile<<"Answer: "<<ans1<<endl;
            break;
        case 2:
            subNumber(number1,number2,&ans2);
            cout<<"Your answer is :"<< ans2<<endl;
            outFile<<"Answer: "<<ans2<<endl;
            break;
        case 3:
            multiNumber(number1,number2,&ans3);
            cout<<"Your answer is :"<<ans3<<endl;
            outFile<<"Answer: "<<ans3<<endl;
            break;
        case 4:
            dividNumber(number1,number2,&ans4);
            cout<<"Your answer is :"<<ans4<<endl;
            outFile<<"Answer: "<<ans4<<endl;
            break;
        default:
            cout << "Error! operator is not correct";
            break;
        }
        break;
        outFile.close();
        }

        case 2:
        {
   ofstream outFile;
   outFile.open("Matrices.txt",fstream::app);
   int a[10][10],b[10][10],c[10][10],s[10][10],f[10][10],v[10][10],m,n,p,q,i,j,k;
   char mat;
   cout<<"Now,please choose your operation for matrices"<<endl;
   cout<<"a:Addition"<<endl;
   cout<<"b:Subtraction"<<endl;
   cout<<"c:Multiplication"<<endl;
   cin>>mat;
    switch(mat)
   {
    case 'a':
    case 'A':
   cout<<"\nEnter the number of rows and columns of matrix A and B:";
   cin>>n>>m;
   for(i=0; i<n;i++)
    {
    for(j=0;j<m;j++)
    {
        cout << "Enter element of Matrix A  : ";
        cin>>s[i][j];
    }
    }
    for(i=0; i<n; i++)
    {
    for(j=0;j<m;j++ )
    {
        cout << "Enter element of Matrix B : ";
        cin>>f[i][j];
    }
    }

      for(i=0; i<n; i++)
     {
      for(j=0;j<m ;j++)
      {
        v[i][j]=s[i][j]+f[i][j];
      }
   }
        cout<<"\nThe result of matrices for addition is :\n";
        outFile<<"\nThe result of matrices for addition is :\n";


        for(i=0; i<n; i++)
        {

         for(j=0; j<m; j++ )
        {

        cout<<setw(5);
        outFile<<setw(5);
        cout<<v[i][j]<<" ";
        outFile<<v[i][j]<<" ";
        }
        cout<<"\n";
        outFile<<"\n";
        }

        break;

    case 'b':
    case 'B':
   cout<<"\nEnter the number of rows and columns of matrix A and B:";
   cin>>n>>m;

   for(i=0; i<n;i++)
    {
    for(j=0;j<m;j++)
    {
        cout << "Enter element of Matrix A  : ";
        cin>>s[i][j];
    }
    }
    for(i=0; i<n; i++)
    {
    for(j=0;j<m;j++ )
    {
        cout << "Enter element of Matrix B : ";
        cin>>f[i][j];
    }
    }

      for(i=0; i<n; i++)
     {
      for(j=0;j<m ;j++)
      {
        v[i][j]=s[i][j]-f[i][j];
      }
   }
        cout<<"\nThe result of matrices for subtraction is :\n";
        outFile<<"\nThe result of matrices for subtraction is :\n";
         for(i=0; i<n; i++)
    {
         for(j=0; j<m; j++ )
    {
        cout<<setw(5);
        cout<<v[i][j]<<" ";
        outFile<<setw(5);
        outFile<<v[i][j]<<" ";
    }
        cout<<"\n";
        outFile<<"\n";
    }
        break;
    case 'c':
    case 'C':
    cout<<"Please enter the same value for column of first matrix and row of second matrix.\n";
    cout<<"Enter rows and columns of first matrix:";
    cin>>m>>n;
    cout<<"Enter rows and columns of second matrix:";
    cin>>p>>q;

    while (n!=p)
    {
        cout << "Error! Multiplication opertion invalid"<<endl;
        cout<<"Column of first matrix not equal to row of second matrix."<<endl;
        cout << "Enter rows and columns for first matrix: ";
        cin >> m >> n;
        cout << "Enter rows and columns for second matrix: ";
        cin >> p >> q;
    }
        for(i=0;i<m;++i)
        {
        for(j=0;j<n;++j)
        {
            cout << "Enter element of first matrix  : ";
            cin>>a[i][j];
        }
        }
        for(i=0;i<p;++i)
        {
        for(j=0;j<q;++j)
        {
            cout << "Enter element of second matrix  : ";
            cin>>b[i][j];
        }
        }

    cout<<"\nThe result of matrices in multiplication is:\n";
     outFile<<"\nThe result of matrices for multiplication is :\n";

    for(i=0;i<m;++i)
    {
        for(j=0;j<q;++j)
    {
        c[i][j]=0;
        for(k=0;k<n;++k)
        c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
        cout<<setw(5);
        cout<<c[i][j]<<" ";
        outFile<<setw(5);
        outFile<<c[i][j]<<" ";
    }
    cout<<"\n";
    outFile<<"\n";
    }

    break;
    default:
    cout<<"Error input"<<endl;
    break;
    }
    break;
     outFile.close();
    }


        case 3:
        {
        ofstream outFile;
        outFile.open("Conversion.txt",fstream::app);
        int z,k, binVal, h=0, integer;
        char hexaDecimal[MAX];
        char convt;
        cout<<"Please choose your conversion"<<endl;
        cout<<"a:Convert decimal  to hexadecimal"<<endl;
        cout<<"b:Convert decimal  to binary"<<endl;
        cout<<"c:Convert hexadecimal  to decimal"<<endl;
        cout<<"d:Convert hexadecimal  to binary"<<endl;
        cout<<"e:Convert binary  to hexadecimal"<<endl;
        cout<<"f:Convert binary  to decimal"<<endl;
        cin>>convt;

        switch(convt)
        {
        case 'a':
        case 'A':
        cout<<"Please enter a decimal value : ";
        cin >> z;
        cout<<"The value of "<<z<<" in hexadecimal is : " << hex << z << endl;
        outFile<<"The value of "<<z<<" in hexadecimal is : "<< hex << z <<endl;
        break;

        case 'b':
        case 'B':
        cout << "Enter a decimal number: ";
        cin >> k;
        binVal = convDecToBin(k);
        cout << k << " in decimal = " << binVal << " in binary" << endl ;
        outFile<< k << " in decimal = "<<binVal<< " in binary"<<endl;
        break;

        case 'c':
        case 'C':
        cout<<"Enter Hexadecimal number "<<endl;
        cin>>hex>>integer;
        cout<<"The decimal number is:"<<integer<<endl;
        outFile<<"The hexadecimal number of "<<integer<<hex<<" in decimal is :"<<integer<<endl;
        break;

        case 'd':
        case 'D':
        cout<<"Enter hexadecimal number: ";
        cin>>hexaDecimal;
        cout<<"The binary value: ";
        outFile<<"\nThe hexadecimal number of "<<hexaDecimal<<" in binary value is: ";
        while(hexaDecimal[h])
        {
        switch(hexaDecimal[h])
        {
             case '0':
             cout<<"0000";
             outFile<<"0000";
             break;
             case '1':
             cout<<"0001";
             outFile<<"0001";
             break;
             case '2':
             cout<<"0010";
             outFile<<"0010";
             break;
             case '3':
             cout<<"0011";
             outFile<<"0011";
              break;
             case '4':
             cout<<"0100";
             outFile<<"0100";
             break;
             case '5':
             cout<<"0101";
             outFile<<"0101";
             break;
             case '6':
             cout<<"0110";
             outFile<<"0110";
             break;
             case '7':
             cout<<"0111";
             outFile<<"0111";
             break;
             case '8':
             cout<<"1000";
             outFile<<"1000";
             break;
             case '9':
             cout<<"1001";
             outFile<<"1001";
             break;
             case 'A':
             cout<<"1010";
             outFile<<"1010";
             break;
             case 'B':
             cout<<"1011";
             outFile<<"1011";
             break;
             case 'C':
             cout<<"1100";
             outFile<<"1100";
             break;
             case 'D':
             cout<<"1101";
             outFile<<"1101";
             break;
             case 'E':
             cout<<"1110";
             outFile<<"1110";
             break;
             case 'F':
             cout<<"1111";
             outFile<<"1111";
             break;
             case 'a':
             cout<<"1010";
             outFile<<"1010";
             break;
             case 'b':
             cout<<"1011";
             outFile<<"1011";
             break;
             case 'c':
             cout<<"1100";
             outFile<<"1100";
             break;
             case 'd':
             cout<<"1101";
             outFile<<"1101";
             break;
             case 'e':
             cout<<"1110";
             outFile<<"1110";
             break;
             case 'f':
             cout<<"1111";
             outFile<<"1111";
             break;
             default:
             cout<<"Invalid hexadecimal value "<<hexaDecimal[h];
             outFile<<"Invalid hexadecimal value "<<hexaDecimal[h]<<endl;
        }

         h++;
        }

        break;
        case 'e':
        case 'E':
        {
        float i,decm=0;
    int d,n,t,q;
    cout<<"Enter any binary number(Only value of 1 and 0):";
    cin>>n;
    t=n;

    for(i=0;n!=0;++i)
    {
    d=n%10;
    decm=(d)*(pow(2,i))+decm;
    n=n/10;
    }

    cout<<"\nThe conversion for binary number of to decimal number is: "<< decm <<endl;
    cout<<"Please follow the answer above:";
    cin>>q;
    cout<<"The value of "<<decm<<" in hexadecimal is : " << hex << q << endl;
    outFile<<"\nThe value of "<<decm<<" in hexadecimal is : " <<hex<<q<<endl;
        break;
        }

        case 'f':
        case 'F':
        {
    float i,nums=0;
    int d,n,t;
    cout<<"Enter any binary number(Only value of 1 and 0):";
    cin>>n;
    t=n;

    for(i=0;n!=0;++i)
    {
    d=n%10;
    nums=(d)*(pow(2,i))+nums;
    n=n/10;
    }
    cout<<"\nThe conversion for binary number of "<<t<<" to decimal number is: "<<nums<<endl;
    outFile<<"\nThe conversion for binary number of "<<t<<" to decimal number is: "<<nums<<endl;

        break;
        }
        default:
        cout<<"Error input"<<endl;
        }
        break;
        outFile.close();
}
    case 4:
    {
    ofstream outFile;
    outFile.open("Trigonometric.txt",fstream::app);
    int no;
    float radian,degree;
    cout<<"\nPlease enter your desired operation:"<<endl;
    cout<<"1. Sine"<<endl;
    cout<<"2. Cosine"<<endl;
    cout<<"3. Tangent"<<endl;
    cout<<"4. Cotangent"<<endl;
    cout<<"5. Cosecant"<<endl;
    cout<<"6. Secant"<<endl;
    cout<<"Your choice :";
    cin>>no;
    cout<<"\nCalculation in radian mode"<<endl;
    cout<<"Angle entered will be converted into radian"<<endl;
    cout<<"\nPlease enter the angle in degree : "<<endl;
    switch(no)
    {
    case (1):
    deg(degree);
    float dsine;
    radian=degree*PI/180.0;
    dsine = sin(radian);
    cout<<"Sine("<<radian<<") = "<<dsine<<endl;
    outFile<<"Sine(radian):\n"<<dsine<<endl;
    break;

    case (2):
    deg(degree);
    float dcosine;
    radian=degree*PI/180.0;
    dcosine = cos(radian);
    cout<<"Cosine("<<radian<<") = "<<dcosine<<endl;
    outFile<<"Cosine(radian):\n"<<dcosine<<endl;
    break;

    case (3):
    deg(degree);
    float dtangent;
    radian=degree*PI/180.0;
    dtangent = tan(radian);
    cout<<"Tangent("<<radian<<") = "<<dtangent<<endl;
    outFile<<"Tangent(radian):\n"<<dtangent<<endl;
    break;

    case (4):
    deg(degree);
    float dcotangent;
    radian=degree*PI/180.0;
    dcotangent = cos(radian)/sin(radian);
    cout<<"Cotangent("<<radian<<") = "<<dcotangent<<endl;
    outFile<<"Cotangent(radian):\n"<<dcotangent<<endl;
    break;

    case (5):
    deg(degree);
    float dcosecant;
    radian=degree*PI/180.0;
    dcosecant = 1/sin(radian);
    cout<<"Cosecant("<<radian<<") = "<<dcosecant<<endl;
    outFile<<"Cosecant(radian):\n"<<dcosecant<<endl;
    break;

    case (6):
    deg(degree);
    float dsecant;
    radian=degree*PI/180.0;
    dsecant = 1/cos(radian);
    cout<<"Secant("<<radian<<") = "<<dsecant<<endl;
    outFile<<"Secant(radian):\n"<<dsecant<<endl;
    break;

    default:
    cout<<"Error input"<<endl;
    }
    break;
    outFile.close();
    }

    case 5:
    {
    ofstream outFile;
    outFile.open("Electric.txt",fstream::app);

    float electricCharge, capacitance, power, current, voltage;
    float v,e,r;
    char aph;

    cout<<"Please enter your desired operation"<<endl;
    cout<<"A. Find the voltage."<<endl;
    cout<<"B. Find the current."<<endl;
    cout<<"C. Find the elctric charge."<<endl;
    cout<<"D. Find the capacitance."<<endl;
    cout<<"E. Find the power."<<endl;
    cin>>aph;

    switch (aph)
    {
    case 'a':
    case 'A':
    curr (e);
    cout<<"The value of current is :"<<e<<endl;
    resistance (r);
    cout<<"The value of resistance is :"<<r<<endl;
    computeVol(e,r,&voltage);
    cout<<"The value of voltage :"<<voltage<<endl;
    outFile<<"\nCurrent\n"<<e<<"A"<<endl;
    outFile<<"Resistance\n"<<r<<"ohm"<<endl;
    outFile<<"Voltage\n"<<voltage<<"V"<<endl<<endl;
    outFile.close();
    break;
    case 'b':
    case 'B':
    volt (v);
    cout<<"The value of voltage is :"<<v<<endl;
    resistance (r);
    cout<<"The value of resistance is :"<<r<<endl;
    computeCur(v,r,&current);
    cout<<"The value of current is :"<<current<<endl;
    outFile<<"\nResistance\n"<<r<<"ohm"<<endl;
    outFile<<"Voltage\n"<<v<<"V"<<endl;
    outFile<<"Current\n"<<current<<"A"<<endl<<endl;
    outFile.close();
    break;
    case 'c':
    case ('C'):
    curr (e);
    cout<<"The value of current is :"<<e<<endl;
    elecCharge(e,&electricCharge);
    cout<<"The value of electric charge is :"<<electricCharge<<endl;
    outFile<<"\nCurrent\n"<<e<<"A"<<endl;
    outFile<<"Electric charge\n"<<electricCharge<<"C"<<endl<<endl;
    outFile.close();
    break;
    case 'd':
    case ('D'):
    volt (v);
    cout<<"The value of voltage is :"<<v<<endl;
    curr (e);
    cout<<"The value of current is :"<<e<<endl;
    capa (e,v,&capacitance);
    cout<<"The value of capacitance is :"<<capacitance<<endl;
    outFile<<"\nVoltage\n"<<v<<"V"<<endl;
    outFile<<"Current\n"<<e<<"A"<<endl;
    outFile<<"Capacitance\n"<<capacitance<<"F"<<endl<<endl;
    outFile.close();
    break;
    case 'e':
    case ('E'):
    volt (v);
    cout<<"The value of voltage is :"<<v<<endl;
    curr (e);
    cout<<"The value of current is :"<<e<<endl;
    powe (v,e,&power);
    cout<<"The value of power is :"<<power<<endl;
    outFile<<"\nVoltage\n"<<v<<"V"<<endl;
    outFile<<"Current\n"<<e<<"A"<<endl;
    outFile<<"Power\n"<<power<<"W"<<endl<<endl;
    outFile.close();
    break;
    default:
    cout<<"Error input"<<endl;
    break;
    }
    break;
    outFile.close();
    }
    case 6:
    {
    ofstream outFile;
    outFile.open("ComputePerimeter.txt",fstream::app);
    char x;
    Rect rectangle;
    Circ circle;
    cout <<"Enter R to find perimeter,area and volume of rectangle"<<endl
         <<"or C to find circumference,area and volume of circle:";
    cin>>x;
    switch (x)
    {
    case 'r':
    case 'R':
    cout<<"Enter the length,width and height of rectangle"<<endl;
    cin>>rectangle.length>>rectangle.width>>rectangle.height;
    rectangle.perimeter=(2*(rectangle.length*rectangle.width));
    rectangle.area=rectangle.length*rectangle.width;
    rectangle.volume=rectangle.length*rectangle.width*rectangle.height;
    cout <<"The perimeter of rectangle is:"<<rectangle.perimeter<<endl;
    cout <<"The area of rectangle is:"<< rectangle.area<<endl;
    cout <<"The volume of rectangle is:"<<rectangle.volume;
    outFile<<"The perimeter of rectangle is : "<<rectangle.perimeter<<endl;
    outFile<<"The area of rectangle is : "<<rectangle.area<<endl;
    outFile<<"The volume of rectangle is : "<<rectangle.volume<<endl;
    outFile.close();
    break ;
    case 'c':
    case 'C':
    cout<<"Enter the radius of circle:"<<endl;
    cin>>circle.radius;
    circle.circumference=2*PI*circle.radius;
    circle.area=PI*circle.radius*circle.radius;
    circle.volume=((4.0/3.0)*PI*circle.radius*circle.radius*circle.radius);
    cout<<"The circumference of circle is:"<<circle.circumference<<endl;
    cout<<"The area of circle is:"<<circle.area<<endl;
    cout<<"The volume of circle is:"<<circle.volume;
    outFile<<"The circumference of circle is : "<<circle.circumference<<endl;
    outFile<<"The area of circle is : "<<circle.area<<endl;
    outFile<<"The volume of circle is : "<<circle.volume<<endl;
    outFile.close();
    break ;
    default:
    cout<<"Syntax Error"<<endl;
    break;
    }
    break;
    outFile.close();
    }
    case 7:
    {

    float a,b,c;
    cout<<"Please enter the value of a, b and c"<<endl;
    cin>>a>>b>>c;
    quadraticAnswer(a,b,c);
    }
}

}
void Values(float &number1,float &number2)
{
cout << "Enter two values to calculate :"<<endl;
cin >> number1>>number2;
}
void addNumber(float number1,float number2,float *ans1)
{
  *ans1=number1+number2;
}
void subNumber(float number1,float number2,float *ans2)
{
  *ans2=number1-number2;

}
void multiNumber(float number1,float number2,float *ans3)
{
  *ans3=number1*number2;

}
void dividNumber(float num1,float num2,float *ans4)
{
  *ans4=num1/num2;

}
int convDecToBin(int k)
{
    int binVal = 0;
    int remainder, h = 1;

    while (k!=0)
    {
        remainder = k%2;
        k /= 2;
        binVal += remainder*h;
        h *= 10;
    }
    return binVal;
}
void deg(float &degree)
{
    cin>>degree;
}
void volt(float &v)
{
    cout<<"Please enter the voltage value: ";
    cin>>v;
}
void curr(float &e)
{
    cout<<"Please enter the current value: ";
    cin>>e;
}
void resistance(float &r)
{
    cout<<"Please enter the resistance value: ";
    cin>>r;
}
void computeVol(float e,float r,float*voltage)
{
    *voltage=e*r;
}
void computeCur(float v,float r, float *current)
{
    *current=v/r;
}
void elecCharge(float e, float *electricCharge)
{
    float t;
    cout<<"Please enter the time : ";
    cin>>t;
    *electricCharge=e*t;
}
void capa(float e, float v, float *capacitance)
{
    float time,q;
    cout<<"Please enter the time to calculate the electric charge: ";
    cin>>time;
    q=e*time;
    cout<<"Electric charge is : "<<q<<endl;
    *capacitance=q/v;
}
void powe( float v, float e, float *power)
{
    *power=e*v;
}
void quadraticAnswer(float a,float b,float c)
{
    ofstream outFile;
    outFile.open("QuadraticEquation.txt",fstream::app);
    float p,root1,root2;
	p=b*b-4*a*c;

	if(p==0)
	{
		root1=(-b)/(2*a);
		root2=root1;
		cout<<"Your roots are equal and same"<<endl;
	    cout<<"\nRoot 1= "<<root1<<"\nRoot 2= "<<root2;
        outFile<<"Answer: "<<"\nRoot 1= "<<root1<<"\nRoot 2= "<<root2<<endl;
  	}
	else if(p>0)
	{
		root1=-(b+sqrt(p))/(2*a);
		root2=-(b-sqrt(p))/(2*a);
		cout<<"You have two roots";
	    cout<<"\nRoot 1= "<<root1<<"\nRoot 2= "<<root2;
	    outFile<<"Answer: "<<"\nRoot 1= "<<root1<<"\nRoot 2= "<<root2<<endl;
	}
	else
	{
		root1=(-b)/(2*a);
		root2=sqrt(-p)/(2*a);
		cout<<"Roots are imaginary";
		cout<<"\nRoot 1="<<root1<<"+"<<root2<<"j";
		cout<<"\nRoot 2="<<root1<<"-"<<root2<<"j";
		outFile<<"Answer: "<<"\nRoot 1="<<root1<<"+"<<root2<<"j\n";
		outFile<<"Answer: "<<"\nRoot 2="<<root1<<"-"<<root2<<"j"<<endl;
	}
	outFile.close();
}


# data[].attributes.body
Mini Project(Coding)

# data[].attributes.body
Mini Project(Report)
1.MUHAMMAD NORHANIFF BIN MD NOH
2. MUHAMMAD SYAHRAN BIN ISMAIL

# data[].attributes.body
Mini project coding

# data[].attributes.body
Mini project report

# data[].attributes.body
mini project(coding)

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <stdio.h>
using namespace std;

#define BASE_16 16
#define MAX 1000

const double PI = 3.14159265;

void OperationList ();
void P1();
void dectoBinHex();
void bintoDecHex();
void hextoDecBin();
float calcChar(float, float);
float calcCapa(float, float);
float calcCurr(float, float);
float calcVolt(float, float);
float calcPow(float, float);
void calcRect();
void calcCirc();
float calcRoot(float, float, float);

const int Row = 3;
const int Column = 3;
struct Rectangle
{
    float length, width, height, perimeter, area, volume;
};

struct Circle
{
    float radius, area, circumference, volume;
};
void calcMatrices ( double [Row][Column] ,double[Row][Column], double[Row][Column], double [Row][Column], double [Row][Column], double [Row][Column]);

int main ()
{
    double d[Row][Column];
    double z[Row][Column];
    double totalSum[Row][Column];
    double subtract[Row][Column];
    double multiply[Row][Column];
    double divide[Row][Column];

    int choice, choice2, choice3, choice4, choice5, choice6;
    int x,y;
    float q, i, t, c, v, r, p;

    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    cout << "This program is an engineering calculator that let you do various calculation." << endl;

    do
    {
        OperationList();
        cin >> choice;
        float radians , degrees;
        switch (choice)
        {
        case 1:
            cout << endl;
            cout << "Choose which operation: " << endl;
            cout << "1. Add" << endl;
            cout << "2. Subtract" << endl;
            cout << "3. Multiply" << endl;
            cout << "4. Divide" << endl;
            P1();
            break;

        case 2:

            calcMatrices(d, z, totalSum, subtract, multiply, divide);
            break;


        case 3:
            cout << endl;
            cout << "Choose from which type: " << endl;
            cout << "1. Decimal" << endl;
            cout << "2. Binary" << endl;
            cout << "3. Hexadecimal" << endl;
            cin >> choice3;
            switch(choice3)
            {
            case 1:
                dectoBinHex();
                break;

            case 2:
                bintoDecHex();
                break;

            case 3:
                hextoDecBin();
                break;
            }
            break;

        case 4:
            cout << fixed << showpoint << setprecision(3);
            cout << "Enter angle in degrees: ";
            cin >> degrees;
            radians = degrees * PI / 180.0;

            cout << "Choose which to calculate: " << endl;
            cout << "1. Cosine" << endl;
            cout << "2. Sine" << endl;
            cout << "3. Tangent" << endl;
            cout << "4. Cotangent" << endl;
            cout << "5. Cosecant" << endl;
            cout << "6. Secant" << endl;
            cin >> choice4;
            switch(choice4)
            {
            case 1: cout << "cosine(radians) = " << cos(radians) << endl;
                break;

            case 2: cout << "sine(radians) = " << sin(radians) << endl;
                break;

            case 3: cout << "tangent(radians) = " << tan(radians) << endl;
                break;

            case 4: cout << "cotangent(radians) = " << atan(radians) << endl;
                break;

            case 5: cout << "cosecant(radians) = " << asin(radians) << endl;
                break;

            case 6:  cout << "secant(radians) = " << acos(radians) << endl;
                break;
            }
            break;

        case 5:
            cout << endl;
            cout << "Choose which to calculate: " << endl;
            cout << "1. Electrical charge (Q = I * t)" << endl;
            cout << "2. Capacitance (C = Q * V)" << endl;
            cout << "3. Current (I = V / R)" << endl;
            cout << "4. Voltage (V = I * R)" << endl;
            cout << "5. Power (P = V * I)" << endl;
            cin >> choice5;
            switch(choice5)
            {
            case 1:
                cout << "Current value (I): ";
                cin >> i;

                cout << "Period (t): ";
                cin >> t;

                calcResfile << "Current value (I): ";
                calcResfile << i << endl;

                calcResfile << "Period (t): ";
                calcResfile << t << endl;

                calcChar(i,t);
                break;

            case 2:
                cout << "Charge (Q): ";
                cin >> q;

                cout << "Voltage (V): ";
                cin >> v;

                calcResfile << "Charge (Q): ";
                calcResfile << q << endl;

                calcResfile << "Voltage (V): ";
                calcResfile << v << endl;

                calcCapa(q,v);
                break;

            case 3:
                cout << "Voltage (V): ";
                cin >> v;

                cout << "Resistance (R): ";
                cin >> r;

                calcResfile << "Voltage (V): ";
                calcResfile << v << endl;

                calcResfile << "Resistance (R): ";
                calcResfile << r << endl;

                calcCurr(v,r);
                break;

            case 4:
                cout << "Current value (I): ";
                cin >> i;

                cout << "Resistance (R): ";
                cin >> r;

                calcResfile << "Current value (I): ";
                calcResfile << i << endl;

                calcResfile << "Resistance (R): ";
                calcResfile << r << endl;

                calcVolt(i,r);
                break;

            case 5:


                cout << "Voltage (V): ";
                cin >> v;

                cout << "Current value (I): ";
                cin >> i;

                calcResfile << "Voltage (V): ";
                calcResfile << v << endl;

                calcResfile << "Current value (I): ";
                calcResfile << i << endl;

                calcPow(v,i);
                break;
            }
            break;

        case 6:
            cout << endl;
            cout << "Choose between rectangle or circle: " << endl;
            cout << "1. Rectangle" << endl;
            cout << "2. Circle" << endl;
            cin >> choice6;
            switch(choice6)
            {
            case 1:
                calcRect();
                break;

            case 2:
                calcCirc();
                break;
            }
            break;

        case 7:
            {
                float a,b,c;
                cout << endl;
                cout << "Enter the value of a, b and c: ";
                cin >> a >> b >> c;

                cout << "Your quadratic functon is: " << a << "x^2"
                << " + " << b << "x" << " + " << c << endl;

                calcResfile << "Enter the value of a, b and c: ";
                calcResfile << a << b << c << endl;
                calcResfile << "Your quadratic functon is: " << a << "x^2"
                << " + " << b << "x" << " + " << c << endl;

                calcRoot (a, b, c);
            }

            break;

        case 8:
            cout << endl;
            cout << "Goodbye and have a nice day." << endl;
            break;

        default:
            cout << "Invalid input" << endl;
            cout << endl;
        }
    }
    while(choice !=8);
    calcResfile.close();

    return 0;
}

void OperationList()
{
    cout << "Please choose the operation you want to use" << endl;
    cout << "1. Addition, subtraction, multiplication and division of scalar values" << endl;
    cout << "2. Addition, subtraction, multiplication of matrices" << endl;
    cout << "3. Conversion between Binary, Hexadecimal and Decimal values" << endl;
    cout << "4. Trigonomteric operations" << endl;
    cout << "5. Electrical charge, capacitance, current, voltage and power" << endl;
    cout << "6. Perimeter, circumference, area and volume of rectangles and circles" << endl;
    cout << "7. Root of quadratic eqauations" << endl;
    cout << "8. Exit" << endl;
}

void P1()
{
            ofstream calcResfile;
            calcResfile.open("calcRes.txt",fstream::app);

            int choice1;
            float x,y;
            cin >> choice1;
            switch(choice1)
            {
            case 1:
                cout << "Enter first number: ";
                cin >> x;
                cout << "Enter second number: ";
                cin >> y;
                cout << "Sum is " << x + y  <<endl;
                cout << endl;

                calcResfile << endl;
                calcResfile << "Enter first number: ";
                calcResfile << x << endl;
                calcResfile << "Enter second number: ";
                calcResfile << y << endl;
                calcResfile << "Sum is " << x + y  <<endl;
                calcResfile << endl;
                break;

            case 2:
                cout << "Enter first number: ";
                cin >> x;
                cout << "Enter second number: ";
                cin >> y;
                cout << "Difference is " << x - y <<endl;
                cout << endl;

                calcResfile << endl;
                calcResfile << "Enter first number: ";
                calcResfile << x << endl;
                calcResfile << "Enter second number: ";
                calcResfile << y << endl;
                calcResfile << "Difference is " << x - y  <<endl;
                calcResfile << endl;
                break;

           case 3:
                cout << "Enter first number: ";
                cin >> x;
                cout << "Enter second number: ";
                cin >> y;
                cout << "Product is " << x * y <<endl;
                cout << endl;

                calcResfile << endl;
                calcResfile << "Enter first number: ";
                calcResfile << x << endl;
                calcResfile << "Enter second number: ";
                calcResfile << y << endl;
                calcResfile << "Product is " << x * y  <<endl;
                calcResfile << endl;
                break;

            case 4:
                cout << "Enter first number: ";
                cin >> x;
                cout << "Enter second number: ";
                cin >> y;
                cout << "Quotient is " << x / y <<endl;
                cout << endl;

                calcResfile << endl;
                calcResfile << "Enter first number: ";
                calcResfile << x << endl;
                calcResfile << "Enter second number: ";
                calcResfile << y << endl;
                calcResfile << "Quotient is " << x / y  <<endl;
                calcResfile << endl;
                break;
            }

            calcResfile.close();

}

void binary(int num)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    int rem;

    if (num <= 1)
    {
        cout << num;
        calcResfile << num;
        return;
    }
    rem = num % 2;
    binary(num / 2);
    cout << rem;
    calcResfile << rem;

    calcResfile.close();
}

void dectoBinHex()
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    char hexValues[] = "0123456789ABCDEF";
    long decimal;
    char hexadecimal[40];
    int index, remainder;

    cout << "Enter decimal number: ";
    cin >> decimal;

    calcResfile << "Enter decimal number: ";
    calcResfile << decimal;

    index = 0;

    if (decimal < 0)
        {
            cout << decimal << " is not a positive integer." << endl;
            calcResfile << decimal << " is not a positive integer." << endl;
        }

    else
        {
            cout << "The binary number is: ";
            calcResfile << "The binary number is: " << endl;
            binary(decimal);
            cout << endl;
            calcResfile << endl;
        }

    while (decimal != 0)
        {
            remainder = decimal % BASE_16;
            hexadecimal[index] = hexValues[remainder];
            decimal /= BASE_16;
            index++;
        }

    hexadecimal[index] = '\0';

    strrev(hexadecimal);



    cout << "The hexadecimal number is: " << hexadecimal << endl;
    cout << endl;

    calcResfile << "The hexadecimal number is: " << hexadecimal << endl;
    calcResfile << endl;

    calcResfile.close();
}

void bintoDecHex()
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    long int bin, hex = 0, i = 1, rem, rem1, num, base=1, dec=0;

    calcResfile << "Enter the binary number: ";
    calcResfile << bin;

    cout << "Enter the binary number: ";
    cin >> bin;
    while (bin!=0)
    {
        rem = bin % 10;
        hex = hex + rem * i;
        i = i * 2;
        bin = bin / 10;

        dec = dec + rem * base;
        base = base * 2;
        num = num / 10;
    }
    printf ("The hexadecimal number is: %1X\n", hex);

    cout << "The decimal number is: "<< dec << endl;
    cout << endl;

    calcResfile << "The decimal number is: "<< dec << endl;
    calcResfile << endl;

    calcResfile.close();
}

void hextoDecBin()
{
 int d;
 cout <<"Entex the hexadecimal: ";
 cin  >> hex >> d;
 cout << "The decimal number is: ";
 cout << d << endl;
}

float calcChar(float i, float t)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    float q;
    q = i * t;

    cout << "Electrical charge: " << q << "C" << endl;
    cout << endl;

    calcResfile << "Electrical charge: " << q << "C" << endl;
    calcResfile << endl;

    calcResfile.close();

    return q;
}

float calcCapa(float q, float v)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    float c;
    c = q / v;

    cout << "Capacitance: " << c << "F" << endl;
    cout << endl;

    calcResfile << "Capacitance: " << c << "F" << endl;
    calcResfile << endl;

    calcResfile.close();

    return c;
}

float calcCurr(float v, float r)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    float i;
    i = v / r;

    cout << "Current: " << i << "A" << endl;
    cout << endl;

    calcResfile << "Current: " << i << "A" << endl;
    calcResfile << endl;

    calcResfile.close();

    return i;
}

float calcVolt(float i, float r)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    float v;
    v = i * r;

    cout << "Voltage: " << v << "V" << endl;
    cout << endl;

    calcResfile << "Voltage: " << v << "V" << endl;
    calcResfile << endl;

    calcResfile.close();

    return v;
}

float calcPow(float v, float i)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    float p;
    p = v * i;

    cout << "Power: " << p << "W" << endl;
    cout << endl;

    calcResfile << "Power: " << p << "W" << endl;
    calcResfile << endl;

    calcResfile.close();

    return p;
}

void calcRect ()
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    Rectangle box1 = {};
    cout << "Insert the length: ";
    cin >> box1.length;
    cout << "Insert the width: ";
    cin >> box1.width;
    cout << "Insert the height: ";
    cin >> box1.height;

    calcResfile << "Insert the length: ";
    calcResfile << box1.length;
    calcResfile << "Insert the width: ";
    calcResfile << box1.width;
    calcResfile << "Insert the height: ";
    calcResfile << box1.height;

    box1.perimeter = (box1.length * 2) + (box1.width * 2);
    box1.area = box1.length * box1.width;
    box1.volume = box1.length * box1.width * box1.height;

    cout << endl;
    cout << "The perimeter of the rectangle is " << box1.perimeter << endl;
    cout << "The area of the rectangle is " << box1.area << endl;
    cout << "The volume of the rectangle is " << box1.volume << endl;
    cout << endl;

    calcResfile << endl;
    calcResfile << "The perimeter of the rectangle is " << box1.perimeter << endl;
    calcResfile << "The area of the rectangle is " << box1.area << endl;
    calcResfile << "The volume of the rectangle is " << box1.volume << endl;
    calcResfile << endl;

    calcResfile.close();
}

void calcCirc()
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    cout << fixed << showpoint << setprecision(3);

    Circle round1 = {};
    cout << "Insert the radius: ";
    cin >> round1.radius;

    calcResfile << "Insert the radius: ";
    calcResfile << round1.radius;

    round1.circumference = 2 * PI * round1.radius;
    round1.area = PI * pow(round1.radius,2);
    round1.volume = (4/3) * PI * pow(round1.radius,3);

    cout << endl;
    cout <<"The circumference of the circle is " << round1.circumference  << endl;
    cout <<"The area of the circle is " << round1.area << endl;
    cout <<"The volume of the circle is " << round1.volume << endl;
    cout << endl;

    calcResfile << endl;
    calcResfile <<"The circumference of the circle is " << round1.circumference  << endl;
    calcResfile <<"The area of the circle is " << round1.area << endl;
    calcResfile <<"The volume of the circle is " << round1.volume << endl;
    calcResfile << endl;

    calcResfile.close();
}

float calcRoot(float a, float b, float c)
{
    ofstream calcResfile;
    calcResfile.open("calcRes.txt",fstream::app);

    float p, root1, root2;
    p = pow(b*b - 4*a*c,0.5);

    if(p<0)
        cout << "No real root" << endl;
        cout << endl;

        calcResfile << "No real root" << endl;
        calcResfile << endl;

    if(p>0)
        cout << "Two real root" << endl;
        root1 = ((b*-1)+sqrt(p))/(2*a);
        root2 = ((b*-1)-sqrt(p))/(2*a);
        cout << "The roots are " << root1 << " and " << root2 << endl;
        cout << endl;

        calcResfile << "Two real root" << endl;
        root1 = ((b*-1)+sqrt(p))/(2*a);
        root2 = ((b*-1)-sqrt(p))/(2*a);
        calcResfile << "The roots are " << root1 << " and " << root2 << endl;
        calcResfile << endl;

    if(p==0)
        cout << "One root" << endl;
        cout << endl;

        calcResfile << "One root" << endl;
        calcResfile << endl;

    calcResfile.close();

    return p;
}

void calcMatrices(double nombor1[Row][Column], double nombor2[Row][Column], double tambah[Row][Column], double tolak[Row][Column], double darab[Row][Column], double bahagi[Row][Column])
{
    cout << "please input the first 9 matrice numbers" << endl;
    for(int row = 0; row < 3; row++)
    {
       for(int column = 0; column < 3; column++)
       {
           cin >> nombor1[row][column];

       }
       cout << endl;
    }

    cout << "please input the second 9 matrice" << endl;
    for(int row = 0; row < 3; row++)
    {
       for(int column = 0; column < 3; column++)
       {

           cin >> nombor2[row][column];

       }
       cout<< endl;
    }
    for(int row = 0; row < 3; row++)
    {
       for(int column = 0; column < 3; column++)
       {
          tambah[row][column] = nombor1[row][column] + nombor2[row][column];
          tolak[row][column] = nombor1[row][column] - nombor2[row][column];
          darab[row][column] = nombor1[row][column] * nombor2[row][column];
          bahagi[row][column] = nombor1[row][column] / nombor2[row][column];
       }
    }

    cout<<"\nThe Result of Matrix summation = number1+number2 is :\n";
    for(int row=0; row<3; row++)
    {
          for(int column=0; column<3; column++ )
          {

            cout << tambah[row][column]<<" ";

          }
            cout<< endl;
    }

    cout<<"\nThe Result of Matrix subtraction = number1-number2 is :\n";
    for(int row=0; row<3; row++)
    {
          for(int column=0; column<3; column++ )
          {

            cout<<tolak[row][column]<<" ";

          }
            cout<<"\n";
    }

    cout<<"\nThe Result of Matrix multiplication = number1 x number2 is :\n";
    for(int row=0; row<3; row++)
    {
           for(int column=0; column<3; column++ )
           {

             cout<<darab[row][column]<<" ";

           }
             cout<<"\n";
    }

    cout<<"\nThe Result of Matrix division = number1/number2 is :\n";
    for(int row=0; row<3; row++)
    {
           for(int column=0; column<3; column++ )
           {

             cout<<bahagi[row][column]<<" ";

           }
             cout<<"\n";
    }

}

# data[].attributes.body
mini project (report)

# data[].attributes.body
Group MAZ:
1)    AMIR DIN SU’AD BIN SHAMSUDDIN
2)   MUHAMMAD ZULHILMI BIN MUSA

3)    MIOR MUHAMMAD ZAIN BIN ABU HARITH
https://drive.google.com/drive/folders/0BzDA3GMlDxxlMV81LVBYOHZ2Y1k

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <fstream>
#include <ctime>
#include <string>
#include <iomanip>
#include <stdlib.h>
#include<cmath>
#include <windows.h>
#define MAX 1000

using namespace std;
int history();
int question1();
int question2();                    //function declaration
int question3();
int question4();
int question5();
int question6();
int question7();
int menu();
int log();
void ElectricalCharge();
void Capacitance();
void Current();
void Voltages();
void Power();
void DecToBin();
void binary (int);
void DecToHex();
void BinToDec();
void BinToHex();
void HexToDec();
void HexToBin();
void menu(int &);
void data(float *,float *);
void menu1(int &);
void data1(double *);
void circle();
void rectangle();
void calculation(float,float,float);
void input(int mat_1st[][10], int mat_2nd[][10], int row_1st, int col_1st, int row_2nd, int col_2nd);
void multiply(int mat_1st[][10], int mat_2nd[][10], int result[][10], int row_1st, int col_1st, int row_2nd, int col_2nd);
void addition(int mat_1st[][10], int mat_2nd[][10], int result[][10], int row_1st, int col_1st, int row_2nd, int col_2nd);
void subtract(int mat_1st[][10], int mat_2nd[][10], int result[][10], int row_1st, int col_1st, int row_2nd, int col_2nd);
void display(int mult[][10], int row_1st, int col_2nd);

struct bulat
{
    float radius;               //structure declaration
    float area;
    float circumference;
    float volume;
};
struct rectangle1
{
    float parameter;            //structure declaration
    float volume;
    float area;
    float length;
    float width;
    float height;
};

const float PI = 3.14159;
const time_t ctt = time(0);             //declaration for current time

int main()
{
    int number;
    do
    {
        cout<<"************************************"<<endl;
        cout<<"*  ENGINEERING CALCULATOR PROGRAM  *"<<endl;
        cout<<"************************************"<<endl;
        cout<<"[1]  Addition, subtraction, multiplication and division operations of scalar values\n"<<endl;
        cout<<"[2]  Addition, subtraction and multiplication of matrices\n"<<endl;
        cout<<"[3]  Conversion between Binary values, Hexadecimal Values and Decimal Values\n"<<endl;
        cout<<"[4]  Trigonometric operations finding cosine, sine, tangent, cotangent, cosecant and secant.\n"<<endl;
        cout<<"[5]  Electrical Charge, Capacitance, Current, Voltages and Power Calculator\n"<<endl;
        cout<<"[6]  Perimeter/Circumference, Area and Volume of rectangles and circles Calculator\n"<<endl;
        cout<<"[7]  Quadratic Equation Calculator\n"<<endl;
        cout<<"[8]  History\n"<<endl;
        cout<<"[9]  Exit\n"<<endl;
        cout<<"\nEnter Your Choice:"<<endl;
        cin>>number;

        if(number==1)
        {
            system("cls");
            question1();                   //Question 1
            system("pause");
            system("cls");
        }
        else if(number==2)
        {
            system("cls");
            question2();                   //Question 2
            system("pause");
            system("cls");
        }
        else if(number==3)
        {
            system("cls");
            question3();                   //Question 3
            system("pause");
            system("cls");
        }
        else if(number==4)
        {
            system("cls");
            question4();                   //Question 4
            system("pause");
            system("cls");
        }
        else if(number==5)
        {
            system("cls");
            question5();                   //Question 5
            system("pause");
            system("cls");
        }
        else if(number==6)
        {
            system("cls");
            question6();                   //Question 6
            system("pause");
            system("cls");
        }
        else if(number==7)
        {
            system("cls");
            question7();                   //Question 7
            system("pause");
            system("cls");
        }
        else if(number==8)
        {
            system("cls");
            history();                     //History
            system("pause");
            system("cls");
        }

    }
    while(number != 9);
    system("cls");
    cout<<"----------------------------------"<<endl;
    cout<<"Thank You For Using This Program"<<endl;
    cout<<"----------------------------------"<<endl;
    return 0;

}
int question1()
{

    float a,b,d,PI;
    char redo;
    int c;

	ofstream outputFile;
	outputFile.open("log.txt",fstream::app);        // Open an output file.
    do
    {
        menu(c);
        PI=3.14159265;
        switch(c)
    {
    case 1:
        outputFile<<"Division Operation"<<endl;             //Division
        outputFile<<"-----------------\n";
        outputFile<<endl;

        data(&a,&b);            //input data
        d=a/b;                  //division formula
        cout<<"Division between this two number is = "<<a/b<<endl;
        outputFile<<"Division between this two number is = "<<a/b<<endl;

    break;
    case 2:
        outputFile<<"Multiplication Operation"<<endl;       //multiplication
        outputFile<<"-----------------\n";
        outputFile<<endl;

        data(&a,&b);            //input data
        d=a*b;                  //multiplication formula
        cout<<"Multiplication between this two number is = "<<a*b<<endl;
        outputFile<<"Multiplication between this two number is = "<<a*b<<endl;
    break;
    case 3:
        outputFile<<"Subtraction Operation"<<endl;          //subtraction
        outputFile<<"-----------------\n";
        outputFile<<endl;

        data(&a,&b);            //input data
        d=a-b;                  //subtraction formula
        cout<<"Subtraction between this two number is = "<<a-b<<endl;
        outputFile<<"Subtraction between this two number is = "<<a-b<<endl;

    break;
    case 4:
        outputFile<<"Addition Operation"<<endl;             //addition
        outputFile<<"-----------------\n";
        outputFile<<endl;

        data(&a,&b);            //input data
        d=a+b;                  //addition formula
        cout<<"Addition between this two number is = "<<a+b<<endl;
        outputFile<<"Addition between this two number is = "<<a+b<<endl;
        break;
        default:
        cout<<"Wrong Input"<<endl;          //if wrong input
        outputFile<<"Wrong Input"<<endl;
    }
    cout<<endl;
    cout<<"enter y to continue or n to terminate:";
    cin>>redo;
    cout<<endl<<endl;


    outputFile << a << endl;
    outputFile << b << endl;
    outputFile << d << endl;
    outputFile<<endl;
    outputFile<<"enter y to continue or n to terminate:"<<endl;
    outputFile<<endl<<endl;




}
    while(redo=='y'||redo=='Y');


	cout << "The numbers were saved to a file.\n";
	outputFile << "The numbers were saved to a file.\n";

// Close the file.
outputFile.close();         //close file
cout << "Done.\n";
outputFile << "Done.\n";
return 0;
}
void menu(int &c)
{
        ofstream outputFile;
        outputFile.open("log.txt",fstream::app);    //open file
        cout<<endl;
        cout<<"******************** Calculator Program ******************\n";
        cout<<"-----------------------\n";
        cout<<"Operations In Scalar\n";
        cout<<"-----------------------\n";
        cout<<"1: Division\t\t"<<endl;              //menu
        cout<<"2: Multiplication\t"<<endl;
        cout<<"3: Subtraction\t\t"<<endl;
        cout<<"4: Addition\t\t"<<endl;
        cout<<endl;
        cout<<"Enter the function that you want to perform : ";
        cin>>c;

        outputFile<<"\n\n**************************************************************"<<endl;
        outputFile<<asctime(localtime(&ctt))<<endl;         //Display current time in log.txt
        outputFile<<endl;
        outputFile<<"******************** Calculator Program ******************\n";
        outputFile<<"-----------------------\n";
        outputFile<<"Operations In Scalar\n";
        outputFile<<"-----------------------\n";
        outputFile<<"Enter the function that you want to perform : "<<endl;
        outputFile<<c<<endl;
        outputFile<<endl;
}
void data(float *A,float *B)
{
        ofstream outputFile;
        outputFile.open("log.txt",fstream::app);
        cout<<"Enter 1st number : ";
        cin>>*A;
        outputFile<<"Enter 1st number : "<<endl;
        outputFile<<*A<<endl;
        cout<<"Enter 2nd number : ";
        outputFile<<"Enter 2nd number : "<<endl;
        cin>>*B;
        outputFile<<*B<<endl;
}

int question2()
{
    ofstream log;                                   // Open an output file.
    log.open ("log.txt",ofstream::app);

	int mat_1st[10][10], mat_2nd[10][10], mult[10][10], row_1st, col_1st, row_2nd, col_2nd, i, j, k,choice;

     while(choice!=4)
     {
        system("cls");
        log<<"\n\n**************************************************************"<<endl;
        log<<asctime(localtime(&ctt))<<endl;        //Display current time in log.txt
        cout<<"-----------------"<<endl;
        cout<< "Matrix Calculator"<<endl;
        cout<<"-----------------"<<endl;
        cout<<"Choose operation"<<endl;             //operation menu
        cout<<"[1] - Addition"<<endl;
        cout<<"[2] - Subtraction"<<endl;
        cout<<"[3] - Multiplication"<<endl;
        cout<<"[4] - Exit"<<endl;
        cin>>choice;

        log<<"-----------------"<<endl;
        log<< "Matrix Calculator"<<endl;
        log<<"-----------------"<<endl;             //store in text file
        log<<"Choose operation"<<endl;
        log<<"[1] - Addition"<<endl;
        log<<"[2] - Subtraction"<<endl;
        log<<"[3] - Multiplication"<<endl;
        log<<"[4] - Exit"<<endl;
        log<<choice;

        if(choice==1)
        {
            cout << "Enter rows and column for first matrix:\n";
            cin >> row_1st >> col_1st;
            cout << "Enter rows and column for second matrix:\n";
            cin >> row_2nd >> col_2nd;

            log << "Enter rows and column for first matrix:\n";
            log << row_1st <<endl<< col_1st<<endl;                      //store in text file
            log << "Enter rows and column for second matrix:\n";
            log << row_2nd <<endl<< col_2nd<<endl;

            if(row_1st==row_2nd && col_1st==col_2nd)
            {
                input(mat_1st, mat_2nd, row_1st, col_1st, row_2nd, col_2nd);
                addition(mat_1st, mat_2nd, mult, row_1st, col_1st, row_2nd, col_2nd);
                display(mult, row_1st, col_2nd);
                system ("pause");
            }
            else
            {       //if the size of matrix 1 is not equal to matrix 2
                cout << "Error! Addition could not take place because number of rows and columns are different between the two matrices." << endl;
                log << "Error! Addition could not take place because number of rows and columns are different between the two matrices." << endl;
                system ("pause");
                system("cls");
            }
        }
        else if(choice==2)
        {
            cout << "Enter rows and column for first matrix:\n";
            cin >> row_1st >> col_1st;
            cout << "Enter rows and column for second matrix:\n";
            cin >> row_2nd >> col_2nd;

            log << "Enter rows and column for first matrix:\n";
            log << row_1st <<endl<< col_1st<<endl;
            log << "Enter rows and column for second matrix:\n";
            log << row_2nd <<endl<< col_2nd<<endl;

            if(row_1st==row_2nd && col_1st==col_2nd)
            {
                input(mat_1st, mat_2nd, row_1st, col_1st, row_2nd, col_2nd);
                subtract(mat_1st, mat_2nd, mult, row_1st, col_1st, row_2nd, col_2nd);
                display(mult, row_1st, col_2nd);
                system ("pause");
            }
            else
            {             //if the size of matrix 1 is not equal to matrix 2
                cout << "Error! Subtraction could not take place because number of rows and columns are different between the two matrices." << endl;
                log << "Error! Subtraction could not take place because number of rows and columns are different between the two matrices." << endl;
                system ("pause");
                system("cls");
            }
        }
        else if(choice==3)
        {
            cout << "Enter rows and column for first matrix:\n";
            cin >> row_1st >> col_1st;
            cout << "Enter rows and column for second matrix:\n";
            cin >> row_2nd >> col_2nd;

            log << "Enter rows and column for first matrix:\n";
            log << row_1st <<endl<< col_1st<<endl;
            log << "Enter rows and column for second matrix:\n";
            log << row_2nd <<endl<< col_2nd<<endl;

            if(col_1st == row_2nd)
            {
                input(mat_1st, mat_2nd, row_1st, col_1st, row_2nd, col_2nd);
                multiply(mat_1st, mat_2nd, mult, row_1st, col_1st, row_2nd, col_2nd);
                display(mult, row_1st, col_2nd);
                system ("pause");
            }
            else
            {              //if column of first matrix not equal to row of second
                cout << "Error! Multiplication could not take place because column of first matrix not equal to row of second." << endl;
                log << "Error! Multiplication could not take place because column of first matrix not equal to row of second." << endl;
                system ("pause");
                system("cls");
            }
        }
        else if(choice==4)
        {

        }
        else
        {
            cout<<"Invalid number"<<endl;           //valid if out of range from 1-4
            log<<"Invalid number"<<endl;
            system ("pause");
        }}
}
void input(int mat_1st[][10], int mat_2nd[][10], int row_1st, int col_1st, int row_2nd, int col_2nd)
{
	int i, j;
	ofstream log;
    log.open ("log.txt",ofstream::app);

	cout << endl << "Enter elements of matrix 1:" << endl;
	log << endl << "Enter elements of matrix 1:" << endl;
	for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_1st; ++j)            //enter element for matrix 1
		{
			cout << "Enter elements a"<< i + 1 << j + 1 << ": ";
			cin >> mat_1st[i][j];
			log << "Enter elements a"<< i + 1 << j + 1 << ": ";
			log << mat_1st[i][j]<<endl;
		}
	}

	cout << endl << "Enter elements of matrix 2:" << endl;
	log << endl << "Enter elements of matrix 2:" << endl;
	for(i = 0; i < row_2nd; ++i)
	{
		for(j = 0; j < col_2nd; ++j)            //enter element for matrix 2
		{
			cout << "Enter elements b" << i + 1 << j + 1 << ": ";
			cin >> mat_2nd[i][j];
			log << "Enter elements b" << i + 1 << j + 1 << ": ";
			log << mat_2nd[i][j]<<endl;
		}
	}
}
void addition(int mat_1st[][10], int mat_2nd[][10], int mult[][10], int row_1st, int col_1st, int row_2nd, int col_2nd)
{
	int i, j, k;


for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_2nd; ++j)
		{
				mult[i][j] = mat_1st[i][j] + mat_2nd[i][j];     //addition formula
		}
	}
}
void subtract(int mat_1st[][10], int mat_2nd[][10], int mult[][10], int row_1st, int col_1st, int row_2nd, int col_2nd)
{
	int i, j;

	for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_2nd; ++j)        //initialize matrix
		{
			mult[i][j] = 0;
		}
	}

for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_2nd; ++j)
		{
				mult[i][j] = mat_1st[i][j] - mat_2nd[i][j];     //subtraction formula
		}
	}
}
void multiply(int mat_1st[][10], int mat_2nd[][10], int mult[][10], int row_1st, int col_1st, int row_2nd, int col_2nd)
{
  ofstream log;
    log.open ("log.txt",ofstream::app);

	int i, j, k;

	for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_2nd; ++j)                    //initialize matrix
		{
			mult[i][j] = 0;
		}
	}

	for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_2nd; ++j)
		{
			for(k=0; k<col_1st; ++k)
			{
				mult[i][j] += mat_1st[i][k] * mat_2nd[k][j];        //multiplication formula
			}
		}
	}
}
void display(int mult[][10], int row_1st, int col_2nd)
{
	int i, j;
	ofstream log;
    log.open ("log.txt",ofstream::app);

	cout << "Output Matrix:" << endl;               //display result
	log << "Output Matrix:" << endl;
	for(i = 0; i < row_1st; ++i)
	{
		for(j = 0; j < col_2nd; ++j)
		{
			cout <<"["<< mult[i][j] << "] ";
			log <<"["<< mult[i][j] << "] ";
			if(j == col_2nd - 1){
				cout << endl << endl;
				log<<endl<<endl;
			}
		}
	}
}

int question3()
{
   ofstream log;
    log.open("log.txt",fstream::app);
    log<<"\n\n**************************************************************"<<endl;
    log<<asctime(localtime(&ctt))<<endl;            //Display current time in log.txt

    int Choice;

    system("cls");
    cout << "*****************************************\n";
    cout << "Please choose your desired conversion: " << endl;
    cout << "*****************************************\n";
    cout << "1-Decimal to Binary\n" << "2-Decimal to Hexadecimal\n" << "3-Binary to Decimal\n" << "4-Binary to Hexadecimal\n"
         << "5-Hexadecimal to Decimal\n" << "6-Hexadecimal to Binary\n" << "7-Exit\n";
    cout << "Your choice -> ";
    cin >> Choice;

    switch(Choice)
    {
        case 1:
        {
            system ("cls");
            DecToBin();             //decimal to binary
        }break;

        case 2:
        {
            system ("cls");
            DecToHex();             //decimal to hex
        }break;

        case 3:
        {
            system ("cls");
            BinToDec();             //binary to decimal
        }break;

        case 4:
        {
            system ("cls");         //binary to hex
            BinToHex();
        }break;

        case 5:
        {
            system ("cls");
            HexToDec();             //hex to decimal
        }break;

        case 6:
        {
            system ("cls");
            HexToBin();             //hex to binary
        }break;

        case 7:
        {
            system("cls");
            cout << "Exited successfully. Thank you!"<<endl;        //exit
        }break;

        default: main();
    }
}

void HexToBin()
{
    ofstream log;
    log.open("log.txt",fstream::app);   //open file

	int i=0, yes;
	char hex[15];
	cout << "Enter your desired Hexadecimal value : ";
	cin >> hex;                 //input hex
	cout << "\nThe Binary value is : ";

	log << "Enter your desired Hexadecimal value : ";
	log << hex;
	log << "\nThe Binary value is : ";

	while(hex[i])
	{
		switch(hex[i])
		{
			case '0' : cout<<"0000";
                       log<<"0000";
				break;
			case '1' : cout<<"0001";
                       log<<"0001";
				break;
			case '2' : cout<<"0010";
                       log<<"0010";
				break;
			case '3' : cout<<"0011";
                       log<<"0011";
				break;
			case '4' : cout<<"0100";
                       log<<"0100";
				break;
			case '5' : cout<<"0101";
                       log<<"0101";
				break;
			case '6' : cout<<"0110";
                       log<<"0110";
				break;
			case '7' : cout<<"0111";
                       log<<"0111";
				break;
			case '8' : cout<<"1000";
                       log<<"1000";
				break;
			case '9' : cout<<"1001";
                       log<<"1001";
				break;
			case 'A' : cout<<"1010";
                       log<<"1010";
				break;
			case 'B' : cout<<"1011";
                       log<<"1011";
				break;
			case 'C' : cout<<"1100";
                       log<<"1100";
				break;
			case 'D' : cout<<"1101";
                       log<<"1101";
				break;
			case 'E' : cout<<"1110";
                       log<<"1110";
				break;
			case 'F' : cout<<"1111";
                       log<<"1111";
				break;
			case 'a' : cout<<"1010";
                       log<<"1010";
				break;
			case 'b' : cout<<"1011";
                       log<<"1011";
				break;
			case 'c' : cout<<"1100";
                       log<<"1100";
				break;
			case 'd' : cout<<"1101";
                       log<<"1101";
				break;
			case 'e' : cout<<"1110";
                       log<<"1110";
				break;
			case 'f' : cout<<"1111";
                       log<<"1111";
				break;
			default : cout<<"\nInvalid hexadecimal digit "<<hex[i];
                      log<<"\nInvalid hexadecimal digit "<<hex[i];
		}
		i++;
	}
cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;

if(yes == 1){
    question3();
}
else{
    system("cls");
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void HexToDec()
{
    ofstream log;
    log.open("log.txt",fstream::app);       //open file

    int x, yes;

    cout << "Please enter the Hexadecimal number : ";
    cin >> hex >> x;        //input data
    cout << "\nThe Decimal value is : " << dec << x; //display result

    log << "Please enter the Hexadecimal number : ";
    log << hex << x;
    log << "\nThe Decimal value is : " << dec << x;

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;

if(yes == 1){
    question3();
}
else{
    system("cls");
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void BinToHex()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    char binnum[MAX], hexa[MAX], x;
        int temp, yes;
        long int i=0,j=0;
        cout<<"\n Enter Binary Number : ";
        cin>>binnum;

        log<<"\n Enter Binary Number : ";
        log<<binnum;
        while(binnum[i])
        {
                binnum[i] = binnum[i] -48;
                ++i;
        }
        --i;
        while(i-2>=0)
        {
                temp =  binnum[i-3] *8 + binnum[i-2] *4 +  binnum[i-1] *2 + binnum[i] ;
                if(temp > 9)
                        hexa[j++] = temp + 55;
                else
                        hexa[j++] = temp + 48;
                i=i-4;
        }
        if(i ==1)
                hexa[j] = binnum[i-1] *2 + binnum[i] + 48 ;
        else if(i==0)
                hexa[j] =  binnum[i] + 48 ;
        else
                --j;
        cout<<"\n Binary Number to Hexadecimal Number : ";

        log<<"\n Binary Number to Hexadecimal Number : ";
        while(j>=0)
        {
                x = hexa[j--];
                cout<< x;
                log << x;
        }   log << endl;

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;

if(yes == 1){
    question3();
}
else{
    system("cls");
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void BinToDec()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    long bin, dec = 0, rem, num, base = 1;
    int yes;

    cout << "Enter the binary number(1s and 0s) : ";
    cin >> num;

    log << "Enter the binary number(1s and 0s) : ";
    log << num;

    bin = num;
    while (num > 0)
    {
        rem = num % 10;
        dec = dec + rem * base;
        base = base * 2;
        num = num / 10;
    }
    cout << "The decimal equivalent of " << bin << " : " << dec << endl;

    log << "The decimal equivalent of " << bin << " : " << dec << endl;

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;

if(yes == 1){
    question3();
}
else{
    system("cls");
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void DecToHex()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    int x, yes;

    cout << "Please enter the decimal number: " << endl;
    cin >> dec >> x;
    cout << "The hexadecimal form of the number is " << hex << x << endl;

    log << "Please enter the decimal number: " << endl;
    log << dec << x;
    log << "The hexadecimal form of the number is " << hex << x << endl;

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;

if(yes == 1){
    question3();
}
else{
    system("cls");
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void DecToBin()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    int dec, bin, yes;
    cout << "Enter the number : ";
    cin >> dec;

    log << "Enter the number : ";
    log << dec;

    if (dec < 0)
    {
        cout << dec << " is not a positive integer." << endl;

        log << dec << " is not a positive integer." << endl;
    }
    else
    {
        cout << "The binary form of " << dec << " is ";

        log << "The binary form of " << dec << " is ";
        binary(dec);
    }

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;

if(yes == 1){
    question3();
}
else{
    system("cls");
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void binary (int num)
{
    ofstream log;
    log.open("log.txt",fstream::app);

    int rem;

    if (num <= 1)
    {
        cout << num;

        log << rem;
        return;
    }
    rem = num % 2;      //formula for binary
    binary (num / 2);
    cout << rem;

    log << rem;
}

int question4()
{

double degrees, radians, d;
    char redo;
    int c;


    ofstream outputFile;
	outputFile.open("log.txt",fstream::app);

	cout<<fixed<<setprecision(3);
    outputFile<<fixed<<setprecision(3); //set to 3 decimal places


do
{

        menu1(c);
        switch(c)

{

    case 1:
        outputFile<<"Sine Operation"<<endl;
        outputFile<<"-----------------\n";
        outputFile<<endl;
        data1(&degrees);
        radians = (degrees * PI / 180.0); //radian formula
        d=sin(radians);                   //sine formula
        cout<<"Sine Answer(radians)= "<<sin(radians)<<endl;
        outputFile<<"Sine Answer(radians) = "<<sin(radians)<<endl;
        outputFile<<endl;
    break;

    case 2:
        outputFile<<"Cosine Operation"<<endl;
        outputFile<<"-----------------\n";
        outputFile<<endl;
        data1(&degrees);
        radians = (degrees * PI / 180.0);   //radian formula
        d=cos(radians);                     //cos formula
        cout<<"Cosine Answer(radians) = "<<cos(radians)<<endl;
        outputFile<<"Cosine Answer(radians) = "<<cos(radians)<<endl;
        outputFile<<endl;
    break;

    case 3:
        outputFile<<"Tangent Operation"<<endl;
        outputFile<<"-----------------\n";
        outputFile<<endl;
        data1(&degrees);
        radians = (degrees * PI / 180.0);   //radian formula
        d=tan(radians);                     //tan formula
        cout<<"Tangent Answer(radians) = "<<tan(radians)<<endl;
        outputFile<<"Tangent Answer(radians) = "<<tan(radians)<<endl;
        outputFile<<endl;
    break;

    case 4:
        outputFile<<"Contangent Operation"<<endl;
        outputFile<<"-----------------\n";
        outputFile<<endl;
        data1(&degrees);
        radians = (degrees * PI / 180.0);   //radian formula
        d=1/tan(radians);                   //cotangent formula
        cout<<"Contangent Answer(radians) = "<<(1/tan(radians))<<endl;
        outputFile<<"Contangent Answer(radians) = "<<(1/tan(radians))<<endl;
        outputFile<<endl;
    break;

    case 5:
        outputFile<<"Cosecant Operation"<<endl;
        outputFile<<"-----------------\n";
        outputFile<<endl;
        data1(&degrees);
        radians = (degrees * PI / 180.0);   //radian formula
        d=1/sin(radians);                   //cosecant formula
        cout<<"Cosecant Answer(radians) = "<<(1/sin(radians))<<endl;
        outputFile<<"Cosecant Answer(radians) = "<<(1/sin(radians))<<endl;
        outputFile<<endl;
    break;

    case 6:
        outputFile<<"Secant Operation"<<endl;
        outputFile<<"-----------------\n";
        outputFile<<endl;
        data1(&degrees);
        radians = (degrees * PI / 180.0);   //radian formula
        d=1/cos(radians);                   //secant formula
        cout<<"Secant Answer(radians) = "<<(1/cos(radians))<<endl;
        outputFile<<"Secant Answer(radians) = "<<(1/cos(radians))<<endl;
        outputFile<<endl;
    break;

    default:
        cout<<"Wrong Input"<<endl;
        outputFile<<"Wrong Input"<<endl;
        }
        cout<<endl;
        cout<<"enter y or Y to continue or n/N to terminate :";
        cin>>redo;
        cout<<endl<<endl;
        outputFile << radians << endl;
        outputFile << d << endl;
        outputFile <<endl;
        outputFile <<"enter y or Y to continue or n/N to terminate :";
        outputFile <<endl<<endl;
}
   while(redo=='y'||redo=='Y');

	cout << "The numbers were saved to a file.\n";
	outputFile<< "The numbers were saved to a file.\n";

	// Close the file.
	outputFile.close();
	cout << "Done.\n";
	outputFile << "Done.\n";
    return 0;
    }

void menu1(int &c)          //menu functtion
{
    ofstream outputFile;
    outputFile.open("log.txt",fstream::app);
    cout<<endl;
    cout<<"******************** Calculator ******************\n";
    cout<<"---------------------------------------------------\n";
    cout<<"\t\tLogarithm Functions\n";
    cout<<"------------------------------------------------\n";
    cout<<"1: Sin\t\t"<<endl;
    cout<<"2: Cosine\t"<<endl;
    cout<<"3: Tan\t\t"<<endl;
    cout<<"4: Cotangent\t\t"<<endl;
    cout<<"5: Cosecant\t\t"<<endl;
    cout<<"6: Secant\t\t"<<endl;
    cout<<endl;
    cout<<"Enter the function that you want to perform : ";
    cin>>c;


    outputFile<<"\n\n**************************************************************"<<endl;
    outputFile<<asctime(localtime(&ctt))<<endl;cout<<endl;
    outputFile<<"******************** Calculator ******************\n";
    outputFile<<"---------------------------------------------------\n";
    outputFile<<"\t\tLogarithm Functions\n";
    outputFile<<"------------------------------------------------\n";
    outputFile<<"Enter the function that you want to perform : "<<endl;
    outputFile<<c<<endl;
    outputFile<<endl;
}
void data1(double *degrees)     //input data function
{
    ofstream outputFile;
    outputFile.open("log.txt",fstream::app);
    cout<<"Enter the angle in degrees : ";
    cin>>*degrees;

    outputFile<<"Enter the angle in degrees : "<<endl;
    outputFile<<*degrees<<endl;
    outputFile<<endl;


}
int question5()
{
    ofstream log;
    log.open("log.txt",fstream::app);
    log<<"\n\n**************************************************************"<<endl;
    log<<asctime(localtime(&ctt))<<endl;              //Display current time in log.txt

    int Choice;

        cout << "*************************************************\n"
             << "Please choose your desired electrical quantity: \n"
             << "*************************************************\n"
             << "1-Electrical Charge (Q)\n2-Capacitance (C)\n3-Current (I)\n4-Voltages (V)\n5-Power (P)\n6-Exit\n\n";
        cout << "Your choice -> ";
        cin >> Choice;
        system("cls");

        switch (Choice)
        {
            case 1:
            {
                ElectricalCharge();
            }
            break;

            case 2:
            {
                Capacitance();
            }
            break;

            case 3:
            {
                Current();
            }
            break;

            case 4:
            {
                Voltages();
            }

            case 5:
            {
                Power();
            }
            break;

            case 6:
            {
                cout<<"Exited successfully. Thank you!"<<endl;
            }
            break;

        default: main();
        }
    }

void ElectricalCharge()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    float q,c,v,i,t,n,e;
    int choice, yes;

    cout << "Choose your desired formula (unit: Coulomb): ";    //menu charge
    cout << "\n\n1-Q = C x V\n2-Q = I x t\n3-Q = n x e\n\n";
    cout << "Your choice -> ";
    cin >> choice;

    log << "Choose your desired formula (unit: Coulomb): ";
    log << "\n\n1-Q = C x V\n2-Q = I x t\n3-Q = n x e\n\n";
    log << "Your choice -> ";
    log << choice;
    system("cls");

    switch(choice)
    {
    case 1:
        {
        cout << "Enter the value for Capacitance,C (unit: Farad): ";
        cin >> c;   //input data
        cout << "\nEnter the value for Voltage,V (unit: Volt): ";
        cin >> v;   //input data
        cout << "\nThe answer is "<< (q=c*v) << "C";    //formula charge

        log << "Enter the value for Capacitance,C (unit: Farad): ";
        log << c;   //input data
        log << "\nEnter the value for Voltage,V (unit: Volt): ";
        log << v;   //input data
        log << "\nThe answer is "<< (q=c*v) << "C";     //formula charge
        }
        break;

    case 2:
        {
        cout << "Enter the value for Current,I (unit: Ampere): ";
        cin >> i;   //input data
        cout << "\nEnter the value for time,t (unit: seconds): ";
        cin >> t;   //input data
        cout << "\nThe answer is "<< (q=i*t) << "C";    //formula charge

        log << "Enter the value for Current,I (unit: Ampere): ";
        log << i;   //input data
        log << "\nEnter the value for time,t (unit: seconds): ";
        log << t;   //input data
        log << "\nThe answer is "<< (q=i*t) << "C";     //formula charge
        }
        break;

    case 3:
        {
        cout << "Enter the value for number of electrons/protons,n: ";
        cin >> n;   //input data
        e = 1.6*pow(10,-19);
        cout << "\nThe answer is "<< (q=n*e) << "C";    //formula charge

        log << "Enter the value for number of electrons/protons,n: ";
        log << n;   //input data
        log << "\nThe answer is "<< (q=n*e) << "C";     //formula charge
        }
        break;
    }

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;
system("cls");

if(yes == 1){
    question5();
}
else{
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void Capacitance()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    float p,a,a1,a2,d,c,q,v;
    int choice,yes;

    cout << "Choose your desired formula (unit: Farad): ";
    cout << "\n\n1-C = (p x A)/D\n2-C = Q/V\n" << "NOTE: p is permittivity of dielectric.\n\n";
    cout << "Your choice -> ";
    cin >> choice;

    log << "Choose your desired formula (unit: Farad): ";
    log << "\n\n1-C = (p x A)/D\n2-C = Q/V\n" << "NOTE: p is permittivity of dielectric.\n\n";
    log << "Your choice -> ";
    log << choice;
    system("cls");

    switch(choice)
    {
    case 1:
        {
            cout << "Enter the value for the length and the width for the area of one plate,A (unit: meters^2): ";
            cin >> a1 >> a2;
            a = a1*a2;
            p = 8.84*pow(10,-12);   //fomula power
            cout << "\nEnter the distance between plates,D (unit: meters): ";
            cin >> d;
            cout << "\nThe answer is "<< ((p*a)/d) << "F";  //formula capacitance

            log << "Enter the value for the length and the width for the area of one plate,A (unit: meters^2): ";
            log << a1 << a2;
            log << "\nEnter the distance between plates,D (unit: meters): ";
            log << d;
            log << "\nThe answer is "<< ((p*a)/d) << "F";   //formula capacitance
        }
        break;

    case 2:
        {
            cout << "Enter the value for Electrical Charge,Q (unit: Coulomb): ";
            cin >> q;
            cout << "\nEnter the value for Voltage, V (unit: Volt): ";
            cin >> v;
            cout << "\nThe answer is " << (c=(q/v)) << "F"; //formula capacitance

            log << "Enter the value for Electrical Charge,Q (unit: Coulomb): ";
            log << q;
            log << "\nEnter the value for Voltage, V (unit: Volt): ";
            log << v;
            log << "\nThe answer is " << (c=(q/v)) << "F";  //formula capacitance
        }
        break;
    }
cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;
system("cls");

if(yes == 1){
    question5();
}
else{
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void Current()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    float i,p,r,v;
    int choice, yes;

    cout << "Choose your desired formula (unit: Ampere): ";
    cout << "\n\n1-I = (P/R)^(1/2)\n2-I = P/V\n3-I = V/R\n\n";
    cout << "Your choice -> ";
    cin >> choice;

    log << "Choose your desired formula (unit: Ampere): ";
    log << "\n\n1-I = (P/R)^(1/2)\n2-I = P/V\n3-I = V/R\n\n";
    log << "Your choice -> ";
    log << choice;
    system("cls");

    switch(choice)
    {
    case 1:
        {
        cout << "Enter the value for Power,P (unit: Watt): ";
        cin >> p;
        cout << "\nEnter the value for Resistance,R (unit: Ohm): ";
        cin >> r;
        cout << "\nThe answer is "<< sqrt(p/r) << "A";  //formula current

        log << "Enter the value for Power,P (unit: Watt): ";
        log << p;
        log << "\nEnter the value for Resistance,R (unit: Ohm): ";
        log << r;
        log << "\nThe answer is "<< sqrt(p/r) << "A";   //formula current
        }
        break;

    case 2:
        {
        cout << "Enter the value for Power,P (unit: Watt): ";
        cin >> p;
        cout << "\nEnter the value for Voltage,V (unit: Volt): ";
        cin >> v;
        cout << "\nThe answer is "<< (i=p/v) << "A";    //formula current

        log << "Enter the value for Power,P (unit: Watt): ";
        log << p;
        log << "\nEnter the value for Voltage,V (unit: Volt): ";
        log << v;
        log << "\nThe answer is "<< (i=p/v) << "A";     //formula current
        }
        break;

    case 3:
        {
        cout << "Enter the value for Voltage,V (unit: Volt): ";
        cin >> v;
        cout << "\nEnter the value for Resistance,R (unit: Ohm): ";
        cin >> r;
        cout << "\nThe answer is "<< (i=v/r) << "A";        //formula current

        log << "Enter the value for Voltage,V (unit: Volt): ";
        log << v;
        log << "\nEnter the value for Resistance,R (unit: Ohm): ";
        log << r;
        log << "\nThe answer is "<< (i=v/r) << "A";         //formula current
        }
        break;
    }

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;
system("cls");

if(yes == 1){
    question5();
}
else{
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void Voltages()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    float v,i,r,p;
    int choice, yes;

    cout << "Choose your desired formula (unit: Volt): ";
    cout << "\n\n1-V = I x R\n2-V = P/I\n3-V = (P x R)^(1/2)\n\n";
    cout << "Your choice -> ";
    cin >> choice;

    log << "Choose your desired formula (unit: Volt): ";
    log << "\n\n1-V = I x R\n2-V = P/I\n3-V = (P x R)^(1/2)\n\n";
    log << "Your choice -> ";
    log << choice;
    system("cls");

    switch(choice)
    {
    case 1:
        {
        cout << "Enter the value for Current,I (unit: Ampere): ";
        cin >> i;
        cout << "\nEnter the value for Resistance,R (unit: Ohm): ";
        cin >> r;
        cout << "\nThe answer is "<< (v=i*r) << "V";    //formula voltage

        log << "Enter the value for Current,I (unit: Ampere): ";
        log << i;
        log << "\nEnter the value for Resistance,R (unit: Ohm): ";
        log << r;
        log << "\nThe answer is "<< (v=i*r) << "V";     //formula voltage
        }
        break;

    case 2:
        {
        cout << "Enter the value for Power,P (unit: Watt): ";
        cin >> p;
        cout << "\nEnter the value for Current,I (unit: Ampere): ";
        cin >> i;
        cout << "\nThe answer is "<< (v=p/i) << "V";     //formula voltage

        log << "Enter the value for Power,P (unit: Watt): ";
        log << p;
        log << "\nEnter the value for Current,I (unit: Ampere): ";
        log << i;
        log << "\nThe answer is "<< (v=p/i) << "V";      //formula voltage
        }
        break;

    case 3:
        {
        cout << "Enter the value for Power,P (unit: Watt): ";
        cin >> p;
        cout << "\nEnter the value for Resistance,R (unit: Ohm): ";
        cin >> r;
        cout << "\nThe answer is "<< sqrt(p*r) << "V";      //formula voltage

        log << "Enter the value for Power,P (unit: Watt): ";
        log << p;
        log << "\nEnter the value for Resistance,R (unit: Ohm): ";
        log << r;
        log << "\nThe answer is "<< sqrt(p*r) << "V";       //formula voltage
        }
        break;
    }

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;
system("cls");

if(yes == 1){
    question5();
}
else{
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

void Power()
{
    ofstream log;
    log.open("log.txt",fstream::app);

    float v,i,r,p;
    int choice, yes;

    cout << "Choose your desired formula (unit: Watt): ";
    cout << "\n\n1-P = (V^2)/R\n2-P = I x V\n3-P = (I^2) x R\n\n";
    cout << "Your choice -> ";
    cin >> choice;

    log << "Choose your desired formula (unit: Watt): ";
    log << "\n\n1-P = (V^2)/R\n2-P = I x V\n3-P = (I^2) x R\n\n";
    log << "Your choice -> ";
    log << choice;
    system("cls");

    switch(choice)
    {
    case 1:
        {
        cout << "Enter the value for Voltage,V (unit: Volt): ";
        cin >> v;
        cout << "\nEnter the value for Resistance,R (unit: Ohm): ";
        cin >> r;
        cout << "\nThe answer is "<< pow(v,2)/r << "W"; //formula power

        log << "Enter the value for Voltage,V (unit: Volt): ";
        log << v;
        log << "\nEnter the value for Resistance,R (unit: Ohm): ";
        log << r;
        log << "\nThe answer is "<< pow(v,2)/r << "W";  //formula power
        }
        break;

    case 2:
        {
        cout << "Enter the value for Current,I (unit: Ampere): ";
        cin >> i;
        cout << "\nEnter the value for Voltage,V (unit: Volt): ";
        cin >> v;
        cout << "\nThe answer is "<< (p=i*v) << "W";    //formula power

        log << "Enter the value for Current,I (unit: Ampere): ";
        log << i;
        log << "\nEnter the value for Voltage,V (unit: Volt): ";
        log << v;
        log << "\nThe answer is "<< (p=i*v) << "W";     //formula power
        }
        break;

    case 3:
        {
        cout << "Enter the value for Current,I (unit: Ampere): ";
        cin >> i;
        cout << "\nEnter the value for Resistance,R (unit: Ohm): ";
        cin >> r;
        cout << "\nThe answer is "<< pow(i,2)*r << "W";  //formula power

        log << "Enter the value for Current,I (unit: Ampere): ";
        log << i;
        log << "\nEnter the value for Resistance,R (unit: Ohm): ";
        log << r;
        log << "\nThe answer is "<< pow(i,2)*r << "W";  //formula power
        }
        break;
    }

cout << "\n\nDo you wish to continue with another operation?";
cout << "\n1-Yes\n2-No\n";
cout << "Your choice -> ";
cin >> yes;
system("cls");

if(yes == 1){
    question5();
}
else{
    cout<<"You are being exited. Thank you!\n";
    cout << "The numbers were saved to a file.\n";

	log << "The numbers were saved to a file.\n";

	cout << "Done.\n";

	log << "Done.\n";
	// Close the file.
	log.close();
}
}

int question6()
{
    int choice;
    ofstream log;
    log.open ("log.txt",ofstream::app);

    log<<"\n\n**************************************************************"<<endl;
    log<<asctime(localtime(&ctt))<<endl;                //Display current time in log.txt

    cout << fixed << showpoint << setprecision(2);
    while(choice != 3)
        {
            choice=menu();
         if(choice==1)
         {
            system("cls");
            circle();       //go to circle function
            system("pause");
            system("cls");
         }
         if(choice==2)
         {
            system("cls");
            rectangle();   //go to rectangle function
            system("pause");
            system("cls");
         }
         else
         {
            cout<<"You enter invalid number"<<endl;

         }}
    system("cls");
    cout<<"***********************************"<<endl;
    cout<<"The result will save into the file"<<endl;
    cout<<"***********************************\n\n"<<endl;
    log.close();
    return 0;
}
int menu()
{
    int choice;
    cout<<"-----------------------"<<endl;
    cout<<"Please choose the shape"<<endl;
    cout<<"-----------------------"<<endl;
    cout<<"[1] - Circle"<<endl;             //menu
    cout<<"[2] - Rectangle"<<endl;
    cout<<"[3] - Exit"<<endl;
    cout << "Selection: ";
    cin >> choice;
    return choice;
}
void circle()
{
    ofstream log;
    log.open ("log.txt",ofstream::app);

    bulat box1;
    cout<<"-------------------------------------"<<endl;
    cout<<"This Program will calculate the area,\nvolume and parameter of circle"<<endl;
    cout<<"-------------------------------------"<<endl;
    cout<<"Enter the follwing information"<<endl;
    cout<<"=>Radius:"<<endl;

    log<<"-------------------------------------"<<endl;
    log<<"This Program will calculate the area,\nvolume and parameter of circle"<<endl;
    log<<"-------------------------------------"<<endl;
    log<<"Enter the follwing information"<<endl;
    log<<"=>Radius:"<<endl;

    cin>>box1.radius;           //inpu radius
    log<<box1.radius;

    box1.circumference=PI*box1.radius*2;                //formula circumference
    box1.volume=(1.33333)*PI*box1.radius*box1.radius*box1.radius;   //formula volume
    box1.area=PI*box1.radius*box1.radius;       // formula area

    cout<<"\n\nThe circumference of circle is:"<<box1.circumference<<"cm"<<endl;
    cout<<"The area of circle is:"<<box1.area<<"cm^2 "<<endl;
    cout<<"The volume of sphere is:"<<box1.volume<<"cm^3 "<<endl;

    log<<"\n\nThe circumference of circle is:"<<box1.circumference<<"cm"<<endl;
    log<<"The area of circle is:"<<box1.area<<"cm^2 "<<endl;
    log<<"The volume of sphere is:"<<box1.volume<<"cm^3 "<<endl;

}
void rectangle()
{
    ofstream log;
    log.open ("log.txt",ofstream::app);

    rectangle1 x1;
    cout<<"----------------------------------------"<<endl;
    cout<<"This Program will calculate the area and \nparameter of rectangle and voume of prism"<<endl;
    cout<<"----------------------------------------"<<endl;
    cout<<"\nEnter the follwing information"<<endl;
    cout<<"Length:"<<endl;
    cin>>x1.length;                 //input length
    cout<<"Width:"<<endl;
    cin>>x1.width;                  //input width
    cout<<"Height:"<<endl;
    cin>>x1.height;                 //input height

    log<<"----------------------------------------"<<endl;
    log<<"This Program will calculate the area and \nparameter of rectangle and voume of prism"<<endl;
    log<<"----------------------------------------"<<endl;
    log<<"\nEnter the follwing information"<<endl;
    log<<"Length:"<<endl;
    log<<x1.length<<endl;
    log<<"Width:"<<endl;
    log<<x1.width<<endl;
    log<<"Height:"<<endl;
    log<<x1.height<<endl;

    x1.parameter=(x1.length*2)+(x1.width*2);        //formula parameter
    x1.area=x1.length*x1.width;                     //formula area
    x1.volume=x1.length*x1.width*x1.height;         //formula volume
    cout<<"\n\nThe parameter of rectangle is:"<<x1.parameter<<"cm"<<endl;
    cout<<"The area of rectangle is:"<<x1.area<<"cm^2 "<<endl;
    cout<<"The volume of rectangle is:"<<x1.volume<<"cm^3 "<<endl;

    log<<"\n\nThe parameter of rectangle is:"<<x1.parameter<<"cm"<<endl;
    log<<"The area of rectangle is:"<<x1.area<<"cm^2 "<<endl;
    log<<"The volume of rectangle is:"<<x1.volume<<"cm^3 "<<endl;
}
int question7()
{

    float A,B,C;
    ofstream log;
    log.open ("log.txt",ofstream::app);

    cout<<"---------------------------"<<endl;
    cout<<"Roots Of Quadratic Equation"<<endl;
    cout<<"---------------------------"<<endl;
    cout<<"Please enter the following information"<<endl;
    cout<<"Enter the value of A:"<<endl;
    cin>>A;                                 //input A
    cout<<"Enter the value of B:"<<endl;
    cin>>B;                                 //input B
    cout<<"Enter the value of C:"<<endl;
    cin>>C;                                 //input C

    log<<"\n\n**************************************************************"<<endl;
    log<<asctime(localtime(&ctt))<<endl;                 //Display current time in log.txt
    log<<"---------------------------"<<endl;
    log<<"Roots Of Quadratic Equation"<<endl;
    log<<"---------------------------"<<endl;
    log<<"Please enter the following information"<<endl;
    log<<"Enter the value of A:"<<endl;
    log<<A<<endl;
    log<<"Enter the value of B:"<<endl;
    log<<B<<endl;
    log<<"Enter the value of C:"<<endl;
    log<<C<<endl;
                                            // display value that have been substitute in formula
    cout<<"\nYour Quadratic Equation Is:\n      "<<A<<"x^2+"<<B<<"x+"<<C<<endl;
    cout<<endl;

    log<<"\nYour Quadratic Equation Is:\n      "<<A<<"x^2+"<<B<<"x+"<<C<<endl;
    log<<endl;

    calculation(A,B,C);
    log.close();
    return 0;
}
void calculation(float A,float B,float C)
{
    ofstream log;
    log.open ("log.txt",ofstream::app);
    float P=0,X1,X2,Q,Z,b,c,D,real,imaginary;
    P=B * B - 4 * A * C;
    if(P<0)
    {
        cout<<"There is no real root"<<endl;
        log<<"There is no real root"<<endl;                 //no real root
        real=(-B)/(2*A);
        imaginary=sqrt(-P)/(2*A);
        cout<<"X1 = "<<real<<" + i"<<imaginary<<endl;
        cout<<"X2 = "<<real<<" - i"<<imaginary<<endl;
        log<<"X1 = "<<real<<" + i"<<imaginary<<endl;
        log<<"X2 = "<<real<<" - i"<<imaginary<<endl;

    cout<<"\n***********************************"<<endl;
    cout<<"The result will save into the file"<<endl;
    cout<<"***********************************\n\n"<<endl;
    }
    else if(P>0)
    {
        cout<<"There is two real root"<<endl;
        log<<"There is two real root"<<endl;                //two real root
        X1 = (-B-sqrt(P))/(2*A);
        X2 = (-B+sqrt(P))/(2*A);
        cout<<"X1="<<X1<<"   X2="<<X2<<endl;
        log<<"X1="<<X1<<"   X2="<<X2<<endl;

    cout<<"\n***********************************"<<endl;
    cout<<"The result will save into the file"<<endl;
    cout<<"***********************************\n\n"<<endl;
    }
    else if(P==0)
    {
        cout<<"There is one root"<<endl;                    //one root
        log<<"There is one root"<<endl;
        X1 = (-B)/(2*A);
        X2 = (-B)/(2*A);
        cout<<"X1="<<X1<<"   X2="<<X2<<endl;
        log<<"X1="<<X1<<"   X2="<<X2<<endl;

    cout<<"\n***********************************"<<endl;
    cout<<"The result will save into the file"<<endl;
    cout<<"***********************************\n\n"<<endl;
    }

}
int history()
{
    system("cls");
    ifstream in("log.txt");

  if(!in) {
    cout << "Cannot open input file.\n";        //if file cant open
    return 1;
  }

  char str[255];

  while(in)
{
    in.getline(str, 255);           //read and display all content in file line by line
    if(in) cout << str << endl;
}

  in.close();
}

# data[].attributes.body
Group MAZ:
1)    AMIR DIN SU’AD BIN SHAMSUDDIN
2)   MUHAMMAD ZULHILMI BIN MUSA

3)    MIOR MUHAMMAD ZAIN BIN ABU HARITH
https://drive.google.com/drive/folders/0BzDA3GMlDxxlMV81LVBYOHZ2Y1k

# data[].attributes.body
CPP file

# data[].attributes.body
Turn-it-in report

# data[].attributes.body
Report

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
const double PI = 3.1415;

//structure
struct ScalarVector
{
    int a;
    int b;
    int c;
} Calc;

//function prototype
void totalAddition();
void totalSubtraction();
void totalMultiplication();
void totalDivision();

ScalarVector calc; //variable for structure
//function prototype
void matricesAddition();
void matricesSubtraction();
void matricesMultiplication();
//function prototype
void convertBinToDec();
void convertDecToBin();
void convertHexToDec();
void convertDecToHex();
void convertBinToHex();
void convertHexToBin();
//function prototype
int computePerimeterRect (int,int);
int computeAreaRect (int, int);
float computeCircumCircle (double);
float computeAreaCircle (double);
//function prototype
void computeQuadrac (double *,double *,double *);
//function prototype
void ScalarVector();
void Matrix();
void Conversion();
void Trigonometrics();
void Electrical();
void RectanglesandCircles();
void QuadraticEquation();
void getHistory();

fstream myBad; // declare myBad as file stream

int main()
{
    int choose;

    cout << "\t\t\t" << "Welcome to Engineering Calculator Program\n" << "\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t\t\t\t" << "Please choose the menu :\n" << "\t\t\t\t" << endl;
    cout << "\t" << "1. Addition, Subtraction, Multiplication and Division of Scalar Vector section\n" << endl;
    cout << "\t" << "2. Addition, Subtraction and Multiplication of Matrix section\n" << endl;
    cout << "\t" << "3. Conversion between Binary values, Hexadecimal Values and Decimals Values section\n" << endl;
    cout << "\t" << "4. Trigonometric operation section\n" << endl;
    cout << "\t" << "5. Compute Electrical Charge, Capacitance, Current, Voltages and Power section\n" << endl;
    cout << "\t" << "6. Compute Perimeter/Circumference, Area and Volumes of rectangles and circles section\n" << endl;
    cout << "\t" << "7. Solve roots of Quadratic Equation\n" << endl;
    cout << "\t" << "8. Check Calculation history\n" << endl;

    cin >> choose;
    // control flow
    switch(choose)
    {
        case 1:
            ScalarVector(); //function calling
            break;

        case 2:
            Matrix(); //function calling
            break;

        case 3:
            Conversion(); //function calling
            break;

        case 4:
            Trigonometrics(); //function calling
            break;

        case 5:
            Electrical();
            break;

        case 6:
            RectanglesandCircles(); //function calling
            break;

        case 7:
            QuadraticEquation(); //function calling
            break;

        case 8:
            getHistory();
            break;

    }

    return 0;
}

void ScalarVector()
{
    int a;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t" << "Addition, Subtraction, Multiplication and Division of Scalar Vector section\n" << "\t\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t" << "Press 1 if you want to use addition operation\n" << endl;
    cout << "\t" << "Press 2 if you want to use subtraction operation\n" << endl;
    cout << "\t" << "Press 3 if you want to use multiplication operation\n" << endl;
    cout << "\t" << "Press 4 if you want to use division operation\n" << endl;
    cin >> a;
    cout << "-------------------------------------------------------------------------------------------" << endl;
//function prototype
    switch(a)
    {
        case 1:
            {
                totalAddition();
                break;
            }

        case 2:
            {
                 totalSubtraction();
                 break;
            }

        case 3:
            {
                totalMultiplication();
                break;
            }

        case 4:
            {
                totalDivision();
                break;
            }
    }
}

void Matrix() //array
{
    int a;

    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout <<  "\t\t" << "Addition, Subtraction and Multiplication of Matrix section\n" << "\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t\t\t\t" << "Please choose the menu :\n" << "\t\t\t\t" << endl;
    cout << "\t" << "Press 1 if you want to use addition in matrices" << endl;
    cout << "\t" << "Press 2 if you want to use subtraction in matrices" << endl;
    cout << "\t" << "Press 3 if you want to use multiplication in matrices" << endl;
    cin >> a;
    cout << "------------------------------------------------------------------------------------------\n" << endl;

    switch(a)
    {
        case 1:
            {
                matricesAddition();
                break;
            }

        case 2:
            {
                 matricesSubtraction();
                 break;
            }

        case 3:
            {
                matricesMultiplication();
                break;
            }

    }
}

void totalAddition()
{
    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Enter two numbers to add : ";
    cin >> calc.a >> calc.b;
    myBad << "Total Addition of Scalar number,\nTwo numbers to add : " << calc.a << " , " << calc.b << endl;

    calc.c = calc.a + calc.b;
    cout << "\t" << "sum of the entered numbers = " << calc.c << endl;
    myBad << "sum of the entered numbers = " << calc.c << endl;

}

void totalSubtraction()
{
    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Enter two numbers to subtract : ";
    cin >> calc.a >> calc.b;
    myBad << "\nTotal Subtraction of Scalar number,\nTwo numbers to subtract : " << calc.a << " , " << calc.b << endl;

    calc.c = calc.a - calc.b;
    cout << "\t" << "total of the entered numbers = " << calc.c << endl;
    myBad << "total of the entered numbers = " << calc.c << endl;

}

void totalMultiplication()
{
    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Enter two numbers to multiply : ";
    cin >> calc.a >> calc.b;
    myBad << "\nTotal Multiplication of Scalar number,\nTwo numbers to multiply : " << calc.a << " , " << calc.b << endl;

    calc.c = calc.a * calc.b;
    cout << "\t" << "total of the entered numbers = " << calc.c << endl;
    myBad << "total of the entered numbers = " << calc.c << endl;

}

void totalDivision()
{
    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Enter two numbers to divide : ";
    cin >> calc.a >> calc.b;
    myBad << "\nTotal Division of Scalar number,\nTwo numbers to divide : " << calc.a << " , " << calc.b << endl;

    calc.c = calc.a / calc.b;
    cout << "\t" << "total of the entered numbers = " << calc.c << endl;
    myBad << "total of the entered numbers = " << calc.c << endl;
}

void matricesAddition()
{
    int r, c, a[100][100], b[100][100], sum[100][100], y, z;

    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Please enter the number of rows (between 1 and 100): ";
    cin >> r;

    cout << "\t" << "Please enter the number of columns (between 1 and 100): ";
    cin >> c;

    cout << endl << "\t" << "Please enter value of first matrices: " << endl;

    for(y = 0; y < r; ++y) // for repetition statement
        for(z = 0; z < c; ++z)
        {
            cout << "\t" << "Please enter the value of a" << y+1 << z+1 << " : ";
            cin >> a[y][z];
        }

    cout << endl << "\t" << "Please enter the value of second matrices: " << endl;

    for(y = 0; y < r; ++y)
        for(z = 0; z < c; ++z)
        {
            cout << "\t" << "Please enter the value of  b" << y+1 << z+1 << " : ";
            cin >> b[y][z];
        }

    for(y = 0; y < r; ++y)
        for(z = 0; z < c; ++z)
            sum[y][z] = a[y][z] + b[y][z];

    myBad << "\nMatrices addition for,\n First matrices:" << endl;

    for(y = 0; y < r; ++y)
    {
        for(z = 0; z < c; ++z)
        {
            myBad << "\t" << a[y][z];
        }
    myBad << endl;
    }

    myBad << "Second matrices:" << endl;

    for(y = 0; y < r; ++y)
    {
        for(z = 0; z < c; ++z)
        {
            myBad << "\t" << b[y][z];
        }
    myBad << endl;
    }

    cout << endl << "\t" << "Sum of two matrices is: " << endl;
    myBad << " Equal to:" << endl;

    for(y = 0; y < r; ++y)
        for(z = 0; z < c; ++z)
        {
            cout << "\t" << sum[y][z] << " ";
            myBad << "\t" << sum[y][z] << " ";
            if(z == c - 1)
                {
                cout << endl;
                myBad << endl;
                }
        }
}

void matricesSubtraction()
{
    int r, c, a[100][100], b[100][100], sum[100][100], y, z;

    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Please enter the number of rows (between 1 and 100): ";
    cin >> r;

    cout << "\t" << "Please enter the number of columns (between 1 and 100): ";
    cin >> c;

    cout << endl << "\t" << "Please enter the value of first matrices: " << endl;

    for(y = 0; y < r; ++y) //for repetition statement
        for(z = 0; z < c; ++z)
        {
            cout << "Please enter value of a" << y+1 << z+1 << " : ";
            cin >> a[y][z];
        }

    cout << endl << "\t" << "Please enter the value of second matrices: " << endl;

    for(y = 0; y < r; ++y)
        for(z = 0; z < c; ++z)
        {
            cout << "\t" << "Please enter the value of b" << y+1 << z+1 << " : ";
            cin >> b[y][z];
        }

    for(y = 0; y < r; ++y)
        for(z = 0; z < c; ++z)
            sum[y][z] = a[y][z] - b[y][z];

    myBad << "\nMatrices substraction for,\n First matrices:" << endl;

    for(y = 0; y < r; ++y)
    {
        for(z = 0; z < c; ++z)
        {
            myBad << "\t" << a[y][z];
        }
    myBad << endl;
    }

    myBad << "\t" << "Second matrices:" << endl;

    for(y = 0; y < r; ++y)
    {
        for(z = 0; z < c; ++z)
        {
            myBad << "\t" << b[y][z];
        }
    myBad << endl;
    }

    cout << endl << "\t" << "Difference of two matrices is: " << endl;
    myBad << " Equal to:" << endl;

    for(y = 0; y < r; ++y)
        for(z = 0; z < c; ++z)
        {
            cout << "\t" << sum[y][z] << " ";
            myBad << "\t" << sum[y][z] << " ";
            if(z == c - 1)
            {
                cout << endl;
                myBad << endl;
            }
        }
}

void matricesMultiplication()
{
    int a[10][10], b[10][10], mult[10][10], r1,c1,r2,c2,y,z,k;

    myBad.open("History.txt", ios::out | ios::app );

    cout << "\t" << "Please enter rows and columns for first matrix: ";
    cin >> r1 >> c1;
    cout << "\t" << "Please enter rows and columns for second matrix: ";
    cin >> r2 >> c2;

    while (c1!=r2)
    {
        cout << "\t" << "Error! column of first matrix not equal to row of second." <<endl;

        cout << "\t" << "Enter rows and columns for first matrix: ";
        cin >> r1 >> c1;

        cout << "\t" << "Enter rows and columns for second matrix: ";
        cin >> r2 >> c2;
    }

    cout<< endl << "\t" << "Please enter the value of matrix 1:" << endl;
    for(y = 0; y < r1; ++y) //for repetition statement
        for(z = 0; z < c1; ++z)
        {
            cout << "\t" << "Please enter the value of a" << y+1 <<  z+1 << ":";
            cin >> a[y][z];
        }

    cout<< endl << "\t" << "Please enter the value of matrix 2:" << endl;
    for(y = 0; y < r2; ++y)
        for(z = 0; z < c2; ++z)
        {
            cout << "\t" << "Please enter the value of b" << y+1 << z+1 << ":";
            cin >> b[y][z];
        }

    for(y = 0; y < r1; ++y)
        for(z = 0; z < c2; ++z)
        {
            mult[y][z]=0;
        }

     myBad << "\nMatrices multiplication for,\n First matrices:" << endl;

    for(y = 0; y < r1; ++y)
    {
        for(z = 0; z < c1; ++z)
        {
            myBad << "\t" << a[y][z];
        }
    myBad << endl;
    }

    myBad << "Second matrices:" << endl;

    for(y = 0; y < r2; ++y)
    {
        for(z = 0; z < c2; ++z)
        {
            myBad << "\t" << b[y][z];
        }
    myBad << endl;
    }

    for(y=0;y<r1;++y)
        for(z=0;z<c2;++z)
            for(k=0;k<c1;++k)
        {
            mult[y][z] += a[y][k] * b[k][z];
        }

    cout<< "\n\t" << "Output Matrix: "<<endl;
    myBad << " Equal to:" << endl;

    for(y=0;y<r1;++y)
    for(z=0;z<c2;++z)
    {
        cout<< "\t" << "    " <<mult[y][z];
        myBad<< "\t" <<mult[y][z];
        if(z == c2-1)
        {
                cout << endl;
                myBad << endl;
        }
    }
}

void Conversion()
{
    int a;
    cout << "---------------------------------------------------------------------------------------------------\n" << endl;
    cout <<  "\t" << "Conversion between Binary values, Hexadecimal Values and Decimals Values section\n" << "\t\t\t" << endl;
    cout << "----------------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t" << "Press 1 if you want to convert binary to decimal\n" << endl;
    cout << "\t" << "Press 2 if you want to convert decimal to binary\n" << endl;
    cout << "\t" << "Press 3 if you want to convert hexadecimal to decimal\n" << endl;
    cout << "\t" << "Press 4 if you want to convert decimal to hexadecimal\n" << endl;
    cout << "\t" << "Press 5 if you want to convert binary to hexadecimal\n" << endl;
    cout << "\t" << "Press 6 if you want to convert hexadecimal to binary\n" << endl;
    cin >> a;


    switch (a)
    {
        case 1:
            {
                convertBinToDec();
                break;
            }

        case 2:
            {
                convertDecToBin();
                break;
            }
        case 3:
            {
                convertHexToDec();
                break;
            }
        case 4:
            {
                convertDecToHex();
                break;
            }
        case 5:
            {
                convertBinToHex();
                break;
            }
        case 6:
            {
                convertHexToBin();
                break;
            }
    }

}

void convertBinToDec()
{
    myBad.open("History.txt", ios::out | ios::app );

    long long d;
    double decNum = 0, i = 0, remainder;

    cout << "\n\t" << "Please enter a binary number: ";
    cin >> d;
    myBad << "\nConvert binary to decimal\nPlease enter a binary number: " << d;

     while (d!=0)
    {
        remainder = d%10;
        d /= 10;
        decNum += remainder*pow(2,i);
        ++i;
    }

    cout << "\n\t" << "The value of binary number in decimal is: " << decNum  << endl;
    myBad <<"\nThe value of binary number in decimal is: " << decNum  << endl;
}


void convertDecToBin()
{
    myBad.open("History.txt", ios::out | ios::app );

    int b ;
    int binaryNumber = 0;
    int remainder, i = 1, step = 1;

    cout << "\n\t" << "Please enter a decimal number: ";
    cin >> b;
    myBad << "\t" << "\nConvert decimal to binary\nPlease enter a decimal number: " << b;

    while (b!=0)
    {
        remainder = b%2;
        cout << "\n\t" << "S" << step++ << ": " << b << "/2, R = " << remainder << ", Quotient = " << b/2 << endl;
        b /= 2;
        binaryNumber += remainder*i;
        i *= 10;
    }

    cout << "\n\t" << "The value of decimal number in binary is: " << binaryNumber  << endl;
    myBad << "\t" << "\nThe value of decimal number in binary is: " << binaryNumber  << endl;
}

void convertHexToDec()
{
    myBad.open("History.txt", ios::out | ios::app );

    int h;

    cout <<  "\n\t" << "Please enter a Hexadecimal number: ";
    cin >> hex >> h;
    myBad << "\nConvert hexadecimal to decimal\nHexadecimal number: " << h;

    cout <<  "\n\t" << "The value of hexadecimal number in decimal is : " << h <<endl;
    myBad << "\nThe value of hexadecimal number in decimal is : " << h <<endl;
}

void convertDecToHex()
{
    myBad.open("History.txt", ios::out | ios::app );

    char variable;
    int num;

    cout << "\n\t" << "Please enter a Decimal number: ";
    cin >> num;
    myBad << "\nConvert decimal to hexadecimal\nDecimal number: " << num;

    cout << "\n\t" << "The value of decimal number in hexadecimal is : "<< hex << num << dec << endl;
    myBad << "\nThe value of decimal number in hexadecimal is : "<< hex << num << dec << endl;

}

void convertBinToHex()
{
    myBad.open("History.txt", ios::out | ios::app );

    long long d;
    double decNum = 0, i = 0, remainder;
    char variable;
    int num;

    cout << "\n\t" << "Please enter a binary number: ";
    cin >> d;
    myBad << "\nConvert binary to hexadecimal\nDecimal number: " << d;

     while (d!=0)
    {
        remainder = d%10;
        d /= 10;
        decNum += remainder*pow(2,i);
        ++i;
    }

    cout << "\n\t" << "The value of binary number in decimal is: " << decNum  << endl;
    myBad << "\nThe value of binary number in decimal is: " << decNum  << endl;

    num=decNum;

    cout << "\n\t" << "The value of decimal number in hexadecimal is : "<< hex << num << dec << endl;
    myBad << "\nThe value of decimal number in hexadecimal is : "<< hex << num << dec << endl;

}

void convertHexToBin()
{
    myBad.open("History.txt", ios::out | ios::app );

    int k;
    int m ;
    int binaryNumber = 0;
    int remainder, i = 1, step = 1;

    cout <<  "\n\t" << "Please enter a Hexadecimal number: ";
    cin >> hex >> m;
    myBad << "\nConvert hexadecimal to binary\nHexadecimal number: ";


    while (m!=0)
    {
        remainder = m%2;
        cout << "\nS" << step++ << ": " << m << "/2, R = " << remainder << ", Quotient = " << m/2 << endl;
        m /= 2;
        binaryNumber += remainder*i;
        i *= 10;
    }

    cout <<  "\n\t" << "The value of hexadecimal number in binary is: " << binaryNumber  << endl;
    myBad <<"\nThe value of hexadecimal number in binary is: " << binaryNumber  << endl;

    k = binaryNumber;
}

void Trigonometrics()
{
 double degrees, radians;
    long cosine,
           sine,
           tangent,
           cotagent,
           cosecant,
           secant;

    myBad.open("History.txt", ios::out | ios::app );

    cout << "-------------------------------------------------------------------------------------------\n" << endl;
    cout <<  "\t\t\t\t" << "Trigonometric operation section\n" << "\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    myBad << "\t" << "Trigonometric operation section\n" << endl;

    cout << "\n\t" << "Please enter angle in degrees: ";
    cin >> degrees;
    myBad << "Please enter angle in degree celsius: ";

    radians = degrees*(PI/180);

    cosine = cos(radians);
    sine = sin(radians);
    tangent = tan(radians);
    cotagent = cos(radians) / tan(radians);
    cosecant = 1 / sin(radians);
    secant = 1 / cos(radians);

    cout << "\n\t" << "cos(radians) = " << cosine << endl;
    myBad << "cos(radians) = " << cosine << endl;
    cout << "\n\t" << "sin(radians) = " << sine << endl;
    myBad << "sin(radians) = " << sine << endl;
    cout << "\n\t" << "tan(radians) = " << tangent << endl;
    myBad << "tan(radians) = " << tangent << endl;
    cout << "\n\t" << "cos(radians) / tan(radians) = " << cotagent << endl;
    myBad << "cos(radians) / tan(radians) = " << cotagent << endl;
    cout << "\n\t" << "1 / sin(radians) = " << cosecant << endl;
    myBad << "1 / sin(radians) = " << cosecant << endl;
    cout << "\n\t" << "1 / cos(radians) = " << secant << endl;
    myBad << "1 / cos(radians) = " << secant << endl;
}

void Electrical()
{
    double I,t,Q,v,R;
    double electricalcharge = 0,
           capacitance = 0,
           current = 0,
           voltage = 0,
           power = 0;

    myBad.open("History.txt", ios::out | ios::app );

    myBad << "This program will compute Electrical Charge, Capacitance, Current, Voltages and Power"<< endl;
    cout << "-------------------------------------------------------------------------------------------\n" << endl;
    cout <<  "\t\t" << "Electrical Charge, Capacitance, Current, Voltages and Power section\n" << "\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t" << "This program will compute Electrical Charge, Capacitance, Current, Voltages and Power\n"<< endl;
    cout << "\t" << "Please enter value for current,A : ";
    cin >> I;
    myBad << "Current= " << I << endl;
    cout << "\t" << "Please enter value for time,s : ";
    cin >> t;
    myBad << "Time= " << t << endl;
    cout << "\t" << "Please enter value for electrical charge,Q : ";
    cin >> Q;
    myBad << "Charge= " << Q << endl;
    cout << "\t" << "Please enter value for electrical voltage,V : ";
    cin >> v;
    myBad << "Voltage= " << v << endl;
    cout << "\t" << "Please enter value for electrical resistor,Ohm : ";
    cin >> R;
    myBad << "Resistor= " << R << endl;

    electricalcharge = I*t;
    capacitance = Q/v;
    current = v/R;
    voltage = I*R;
    power = I*v;

    cout << "\n\t" << "The value of Electrical charge in Coloumbs is = " << electricalcharge << endl;
    myBad << "\nThe value of Electrical charge in Coloumbs is = " << electricalcharge << endl;
    cout << "\t" << "The value of Capacitance in Farad is = " << capacitance << endl;
    myBad << "The value of Capacitance in Farad is = " << capacitance << endl;
    cout << "\t" << "The value of Current in Ampere is = " << current << endl;
    myBad << "The value of Current in Ampere is = " << current << endl;
    cout << "\t" << "The value of Voltage in Volts is = " << voltage << endl;
    myBad << "The value of Voltage in Volts is = " << voltage << endl;
    cout << "\t" << "The value of Power in Watts is = " << power << endl;
    myBad << "The value of Power in Watts is = " << power << endl;
}

void RectanglesandCircles()
{
    int length, width;
    double radius;
    float P,A, C, R;

    myBad.open("History.txt", ios::out | ios::app );

    myBad << "\nThis program will Compute Perimeter/Circumference, Area and Volumes of rectangles and circles\n" << endl;
    cout << "-------------------------------------------------------------------------------------------\n" << endl;
    cout <<  "\t\t" << "Perimeter/Circumference, Area and Volumes of rectangles and circles section\n" << "\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t" << "This program will Compute Perimeter/Circumference, Area and Volumes of rectangles and circles\n" << endl;
    cout << "\t" << "Please enter the length and width of a rectangle :";
    cin >> length >> width;
    myBad << "length and width of a rectangle :"<< length << " , " << width << endl;
    cout << "\t" << "Please enter the radius of circle :";
    cin >> radius;
    myBad << "the radius of circle :" << radius << endl;

    P = computePerimeterRect(length,width);
    A = computeAreaRect(length,width);
    C = computeCircumCircle (radius);
    R = computeAreaCircle (radius);

    cout << "\n\t" << "The perimeter of rectangle is :" << P << endl;
    myBad << "The perimeter of rectangle is :" << P << endl;
    cout << "\t" << "The area of rectangle is :" << A << endl;
    myBad << "The area of rectangle is :" << A << endl;
    cout << "\t" << "The circumference of circle is: " << C <<endl;
    myBad << "The circumference of circle is: " << C <<endl;
    cout << "\t" << "The area of circle is " << R <<endl;
    myBad << "The area of circle is " << R <<endl;
}

int computePerimeterRect (int length, int width)
{
    return 2*(length+width);
}

int computeAreaRect (int length, int width)
{
    return length*width;
}

float computeCircumCircle (double radius)
{
    return 2*PI*radius;
}

float computeAreaCircle (double radius)
{
    return PI*pow(radius,2);
}

void QuadraticEquation()
{
    myBad.open("History.txt", ios::out | ios::app );

    double a,b,c;
    cout << "-------------------------------------------------------------------------------------------\n" << endl;
    cout <<  "\t\t\t\t" << "Quadratic Equation section\n" << "\t\t\t" << endl;
    cout << "------------------------------------------------------------------------------------------\n" << endl;
    cout << "\t" << "Please enter the value of a,b and c:";
    cin >> a >> b >> c;
    myBad << "\nQuadratic  Equation,\nValue of a,b and c:" << a << ' ' << b << ' ' << c;
    cout << "\t" << "Your quadratic equation is : " << a << "x^2 + " << b << "x +" << c << endl;
    myBad << "\nYour quadratic equation is : " << a << "x^2 + " << b << "x +" << c << endl;
    computeQuadrac (&a,&b,&c); //send address of a,b,c

}
void computeQuadrac (double *a,double *b,double *c) //pointer
{
    myBad.open("History.txt", ios::out | ios::app );

    double r=( *b * *b)-(4 * *a * *c);
    if (r>0)
    {
        cout << "\t" << "There is two real roots" << endl;
        myBad << "There is two real roots" << endl;
        double x = (- *b + pow (r ,0.5))/(2 * *a);
        double y = (- *b - pow (r,0.5))/(2 * *a);
        cout << "\t" << "The root is: " << x << "and" << y;
        myBad << "The root is: " << x << "and" << y;
    }

    else if (r==0)
    {
        cout << "\t" << "There is one real root" << endl;
        myBad << "There is one real root" << endl;
        double x = (- *b + pow (r,0.5))/(2 * *a);
        cout << "\t" << "The root is: " << x ;
        myBad << "The root is: " << x ;
    }

    else// (r<0)
    {
        cout << "\t" << "There is no real root"<<endl;
        myBad << "There is no real root" <<endl;

    }
}

void getHistory()
{
    string line;
    ifstream myBad ("History.txt");

    if(myBad.is_open())
    {
        while(myBad.good())
        {
            getline(myBad,line);
            cout << "\n\t" << line << endl;
        }
        myBad.close();
    }
    else
        cout <<"\n\t" << " Unable to open file" << endl;
}


# data[].attributes.body
Flowchart B and C in different Microsoft Word because in landscape layout

# data[].attributes.body
Group: MVP
Muhmmad afiq
Muhammad haziq
Muhammad saifuddien

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
#include <cmath>
#include <iomanip>
#include <stdlib.h>
#include <fstream>
void quadratic(double&,double&,double&);
void binary(int &);
void hexaDecimal(int &);
struct Num1
{
    float charge, capacitance, current, voltage, power;
    float time;
    int choice, x;

};
Num1 electric;
void electricalCalculator();
void basicCalculator();
struct rectangle
{
   float length;
   float width;
   float height;
   float area;
   float perimeter;
   float volume;
};
float calc_perimeter_circle(float);
float calc_area_circle(float);
float calc_volume_circle(float);
struct Num2
{
    float angle, radian;
    float dsin, dcos, dtan, dcot, dcsc, dsec;
    int choice3, y;
};
Num2 trigo;

void trigoCalculator();
int main()
{
    int x;
    cout<<"Choose which type of operation you want to use"<<endl;
    cout<<".............................................."<<endl;
    cout<<"1)Arithmetic Operation"<<endl;
    cout<<"2)Matrices"<<endl;
    cout<<"3)Conversion"<<endl;
    cout<<"4)Trigonometric Function"<<endl;
    cout<<"5)Electrical Formula"<<endl;
    cout<<"6)Perimeter/Circumference and Area"<<endl;
    cout<<"7)Quadratic"<<endl;
    cout<<".............................................."<<endl;
    cout<<"The operation that I want to use is(press (-1) to quit):";
    cin>>x;
    system ("cls");

    switch(x)
{
    case(1):
    {
        ofstream outfile;
        outfile.open("Basic operation.txt",fstream::app);
    int i,x;
    double d;
    cout<<"--------------------------------"<<endl;
    cout<<"1)Addition"<<endl;
    cout<<"2)Subtraction"<<endl;
    cout<<"3)Multiplication"<<endl;
    cout<<"4)Division"<<endl;
    cout<<"--------------------------------"<<endl;
    cout<<"Your choice(-1 for quit)?:";
    cin>>i;
    system("cls");
        if(i==1)
        {
            double sum=0;
            cout<<"You choose addition"<<endl;
            for(x=1;x<=5;x++)
            {
            cout<<"Enter the value for"<<" "<<x<<":";
            cin>>d;
            sum+=d;
            }

            cout<<"\nTotal for addition is"<<" "<<sum<<endl;
            outfile<<"Total for addition is"<<" "<<sum<<endl;
            break;
        }
        else if(i==2)
        {
            double sum=0,a;
            cout<<"You choose subtraction"<<endl;
            cout<<"Enter the value for"<<" "<<"1"<<" "<<"and"<<" "<<"2"<<":";
            cin>>d>>a;
            sum=d-a;

            cout<<"\nTotal for subtraction is"<<" "<<sum<<endl;
            outfile<<"Total for subtraction is"<<" "<<sum<<endl;
            break;

        }
        else if(i==3)
        {
            double sum1=1;
            cout<<"tYou choose multiplication"<<endl;
            for(x=1;x<=5;x++)
            {
            cout<<"tEnter the value for"<<" "<<x<<":";
            cin>>d;
            sum1*=d;
            }
            cout<<"\nTotal for multiplication is:"<<" "<<sum1<<endl;
            outfile<<"Total for multiplication is:"<<" "<<sum1<<endl;
            break;
        }

        else if(i==4)
        {
            double sum1,a;
            cout<<"tYou choose division"<<endl;
            cout<<"Enter the value for"<<" "<<"1"<<" "<<"and"<<" "<<"2"<<":";
            cin>>d>>a;
            sum1=d/a;

            cout<<"\nTotal for division is:"<<" "<<sum1<<endl;
            outfile<<"Total for division is:"<<" "<<sum1<<endl;
            break;
        }

        else
        {
            cout<<"You can use another operation"<<endl;

        }
        outfile.close();
    }
    break;
    case(2):
    {
        ofstream outfile;
        outfile.open("Matrices.txt",fstream::app);
        int i;
        cout<< "____________________________________"<<endl;
        cout<<"1)Matrices in addition"<<endl;
        cout<<"2)Matrices in subtraction"<<endl;
        cout<<"3)Matrices in multiplication"<<endl;
        cout<< "____________________________________"<<endl;
        cout<< "Which matrices?:";
        cin>>i;
        system ("cls");
        if(i==1)
        {
           float row, column, matrix1[10][10], matrix2[10][10], matrixSum[10][10];
            cout << "Enter the number of rows and columns: " << endl;
            cin >> row >> column;

            cout << "\nEnter the elements of first matrix: " << endl;   // Store elements of the first matrix by the user
            for(int i = 1; i <= row; i++)
                for(int j = 1; j <= column; j++)
            {
                    cout << "Please enter the element of a" << i  << j << " : ";
                    cin >> matrix1[i][j];
            }

            cout << "\nPlease enter the elements of second matrix: " << endl;   // Store elements of the second matrix by the user
            for(int i = 1; i <= row; i++)
                for(int j = 1; j <= column; j++)
            {
                    cout << "Please enter the element of b" << i << j << " : ";
                    cin >> matrix2[i][j];
            }


            for(int i = 1; i <= row; i++)     // Adding two matrix
                for(int j = 1; j <= column; j++)
                matrixSum[i][j] = matrix1[i][j] + matrix2[i][j];

            cout << "\nThe sum of the two matrix is: " << endl;   // Display the result of the sum
            for(int i = 1; i <= row; i++)
                for(int j = 1; j <= column; j++)
            {
                cout << setw(5) << matrixSum[i][j];
                if(j == column)
                cout << endl;

            }
            outfile << "\nThe sum of the two matrix is: " << endl;   // Display the result of the sum
            for(int i = 1; i <= row; i++)
                for(int j = 1; j <= column; j++)
            {
                outfile << setw(5) << matrixSum[i][j];
                if(j == column)
                outfile << endl;

            }
        }
        else if(i==2)
        {
           float row, column, matrix1[10][10], matrix2[10][10], matrixSub[10][10];

    cout << "Enter the number of rows and columns: " << endl;
    cin >> row >> column;

    cout << "\nEnter the elements of first matrix: " << endl;   // Store elements of the first matrix by the user
    for(int i = 1; i <= row; i++)
       for(int j = 1; j <= column; j++)
       {
           cout << "Please enter the element of a" << i  << j << " : ";
           cin >> matrix1[i][j];
       }

    cout << "\nPlease enter the elements of second matrix: " << endl;   // Store elements of the second matrix by the user
    for(int i = 1; i <= row; i++)
       for(int j = 1; j <= column; j++)
       {
           cout << "Please enter the element of b" << i << j << " : ";
           cin >> matrix2[i][j];
       }


    for(int i = 1; i <= row; i++)     // Subtract two matrix
        for(int j = 1; j <= column; j++)
            matrixSub[i][j] = matrix1[i][j] - matrix2[i][j];

    cout << "\nThe sub of the two matrix is: " << endl;   // Display the result of the subtraction
    for(int i = 1; i <= row; i++)
        for(int j = 1; j <= column; j++)
        {
            cout << setw(5) << matrixSub[i][j];
            if(j == column)
            cout << endl;
        }
        outfile << "\nThe sub of the two matrix is: " << endl;   // Display the result of the subtraction
    for(int i = 1; i <= row; i++)
        for(int j = 1; j <= column; j++)
        {
            outfile << setw(5) << matrixSub[i][j];
            if(j == column)
            outfile << endl;
        }

        }
        else if(i==3)
        {
           float matrix1[10][10], matrix2[10][10], mult[10][10], row1, column1, row2, column2;

    cout << "Enter the number of rows and columns for first matrix: " << endl;
    cin >> row1 >> column1;
    cout << "Enter the number of rows and columns for second matrix: " << endl;
    cin >> row2 >> column2;

    while (column1!=row2)
    {
        cout << "\aError! Try again." << endl << endl;

        cout << "Enter the number of rows and columns for first matrix: " << endl;
        cin >> row1 >> column1;

        cout << "Enter the number of rows and columns for second matrix: " << endl;
        cin >> row2 >> column2;
    }


    cout << "\nPlease enter the elements of first matrix: " << endl;  // Store elements of the first matrix by the user
    for(int i = 1; i <= row1; i++)
        for(int j = 1; j <= column1; j++)
        {
            cout << "Please enter the element of a" << i  << j << " : ";
            cin >> matrix1[i][j];
        }


    cout << "\nPlease enter the elements of second matrix: " << endl;  // Store elements of the second matrix by the user
    for(int i = 1; i <= row2; i++)
        for(int j = 1; j <= column2; j++)
        {
            cout << "Please enter the element of b" << i << j << " : ";
            cin >> matrix2[i][j];
        }


    for(int i = 1; i <= row1; i++)                    // Initializing elements of matrix mult to 0.
        for(int j = 1; j <= column2; j++)
        {
            mult[i][j]=0;
        }


    for(int i = 1; i <= row1; i++)                    // Multiplying matrix a and b and storing in array mult.
        for(int j = 1; j <= column2; j++)
            for(int k = 1; k <= column1; k++)
            {
                mult[i][j] += matrix1[i][k] * matrix2[k][j];
            }


    cout << "\nThe multiply of the two matrix is: " << endl;
    for(int i = 1; i <= row1; i++)                    // Display the result of the multiplication
        for(int j = 1; j <= column2; j++)
    {
        cout << setw(6) << mult[i][j];
        if(j == column2)
        cout << endl;
    }
    outfile << "\nThe multiply of the two matrix is: " << endl;
    for(int i = 1; i <= row1; i++)                    // Display the result of the multiplication
        for(int j = 1; j <= column2; j++)
    {
        outfile << setw(6) << mult[i][j];
        if(j == column2)
        outfile << endl;
    }
        }
    else
    {
        cout<<"You can use another operation"<<endl;
    }
    }
    break;
    case(3):
{
    {
    int a,b;
    cout<<"Convert the decimal number"<<endl;
    cout<<"---------------------------"<<endl;
    cout<<"\t1)Binary"<<endl;
    cout<<"\t2)Hexadecimal"<<endl;
    cout<<"---------------------------"<<endl;
    cout<<"Which one?(1 or 2):";
    cin>>a;
    system ("cls");
    if(a==1)
    {
        cout<<"You have choose convert from decimal to binary"<<endl;
        binary(a);
    }
    else
    {
        cout<<"You have choose convert from decimal to hexadecimal"<<endl;
        hexaDecimal(b);
    }
    }
    break;
}
    case(4):
        {
            cout<< "Now, you are using this Trigonometric Calculator";
            trigoCalculator();
        }
        break;
    case(5):
        {
            cout<< "Now, you can use this electricalCalculator"<<endl;
            electricalCalculator();
        }
        break;
        case(6):
            {
                ofstream outfile;
                outfile.open("circle and rectangle.txt",fstream::app);
                int i;
                cout<<"Enter 1 for circle and 2 for rectangle(-1 to quit):";
                cin>>i;
            while(i!=-1)
            {
                if(i==1)
                {
                    int calc_choice, rad;

                    const int PERIMETER = 1,
                    AREA = 2,
                    VOLUME = 3,
                    QUIT = 4;

    cout << "***CIRCLE***"<<endl<<endl;

    cout<< "1. PERIMETER"<<endl;
    cout<< "2. AREA"<<endl;
    cout<< "3. VOLUME"<<endl;
    cout<< "4. QUIT"<<endl<<endl;

    cout<< "Choose your operation : " << endl;
    cin >> calc_choice;

   switch (calc_choice)
   {
      case PERIMETER:
          cout << "Radius of circle: " << endl;
          cin >> rad;
          cout << "The circumference of the circle is :\n " <<calc_perimeter_circle(rad)<<endl;
          outfile << "The circumference of the circle is :\n " <<calc_perimeter_circle(rad)<<endl;
          break;
      case AREA:
          cout << "Radius of circle?: " << endl;
          cin >> rad;
          cout << "The area of the circle is :\n " << calc_area_circle(rad) << endl;
          outfile << "The area of the circle is :\n " << calc_area_circle(rad) << endl;
          break;
      case VOLUME:
          cout << "Radius of circle?: " << endl;
          cin >> rad;
          cout << "The volume of the circle is :\n " << calc_volume_circle(rad) << endl;
          outfile << "The volume of the circle is :\n " << calc_volume_circle(rad) << endl;
          break;

      case QUIT:
         cout << "Program ending.\n";
         break;

      default:
         cout << "Those are invalid number. Run the\n"
              << "program again and select one of those.\n";
   }
                    break;
                }
                else if(i==2)
                {
                    rectangle container;
   cout<< "***RECTANGLE***" << endl;

   cout << "Length of the rectangle?: ";
   cin >> container.length;           // read the length member of box

   cout << "Width of the rectangle?: ";
   cin >> container.width;           // read the width member of box

   cout << "Height of the rectangle?: ";
   cin >> container.height;           // read the height member of box


   container.area = container.length * container.width;                   // compute the area member of box
   container.perimeter = 2 * container.length + 2 * container.width;      // compute the perimeter member of box
   container.volume = container.length * container.width * container.height;    // compute the volume member of box

   cout << "\nRectangle :\n"
        <<"Perimeter = " << container.perimeter << endl
        << "Area = " << container.area << endl
        << "Volume = " << container.volume << endl;
   outfile<<"Perimeter = " << container.perimeter << endl;
    outfile<< "Area = " << container.area << endl;
        outfile<< "Volume = " << container.volume << endl;
                    break;
                }
                else
                {
                    cout<<"Not in range, Try Again"<<endl;
                    cout<<"Enter 1 for circle and 2 for rectangle(-1 to quit):";
                    cin>>i;
                }

            }
                outfile.close();
            }

        break;
        case(7):
    {
        double a,b,c,determinant;
        cout<<"This is Quadratic . Enter value a,b and c:";
        cin>>a>>b>>c;
        cout<<"Equation are"<<" "<<a<<"x^2"<<"+"<<b<<"x"<<"+"<<c<<endl;
        quadratic(a,b,c);
        break;
    }
    default:
    {
        cout<<"THANK YOU FOR USING MVP CALCULATOR"<<endl;
    }
    if(x==-1)
    {
        return 0;
    }
    else
    {
        cout<<"Try again"<<endl;
    }
}


main();

}
void quadratic(double &x,double &y,double&z)
{
    ofstream outfile;
    outfile.open("Quadratic.txt",fstream::app);
    double x1,x2,deter,actualPart,imaginPart;
    deter=(y*y - 4*x*z);
if (deter > 0)
    {
        x1 = (-y + sqrt(deter)) / (2*x);
        x2 = (-y - sqrt(deter)) / (2*x);
        cout << "It have real and different root." << endl;
        cout << "x1 = " << x1 << endl;
        cout << "x2 = " << x2 << endl;
        outfile << "It have real and different root." << endl;
        outfile << "x1 = " << x1 << endl;
        outfile << "x2 = " << x2 << endl;
    }

    else if (deter == 0)
    {
        cout << "It have real and  same root." << endl;
        x1 = (-y + sqrt(deter)) / (2*x);
        cout << "x1 = x2 =" << x1 << endl;
        outfile << "It have real and  same root." << endl;
        outfile << "x1 = x2 =" << x1 << endl;
    }

    else
    {
        actualPart = (-y/(2*x));
        imaginPart =sqrt(-deter)/(2*x);
        cout << "It have complex and same root."  << endl;
        cout << "x1 = " << actualPart << "+" << imaginPart << "i" << endl;
        cout << "x2 = " << actualPart << "-" << imaginPart << "i" << endl;
        outfile << "It have complex and same root."  << endl;
        outfile << "x1 = " << actualPart << "+" << imaginPart << "i" << endl;
        outfile<< "x2 = " << actualPart << "-" << imaginPart << "i" << endl;
    }
    outfile.close();
}
void binary(int &x)
{
    ofstream outfile;
    outfile.open("conversion.txt",fstream::app);
    int sum=0,i=1,remainder;
    cout<<"Enter the decimal:";
    cin>>x;
    do
    {
        remainder=x%2;
        sum=sum+(i*remainder);
        x=x/2;
        i=i*10;
    }
    while(x>0);
    cout<<"the binary is:"<<sum<<endl;
    outfile<<"the binary is:"<<sum<<endl;
    outfile.close();
}
void hexaDecimal(int &y)
{
    ofstream outfile;
    outfile.open("conversion.txt",fstream::app);
    cout<<"Decimal?:";
    cin>>y;
    cout<<"Decimal in hexadecimal form is"<<" "<<hex<<y<<endl;
    outfile<<"Decimal in hexadecimal form is"<<" "<<hex<<y<<endl;
    outfile.close();
}
void electricalCalculator()
{
    ofstream outfile;
    outfile.open("Electric Calculator.txt",fstream::app);
    cout<< "Electrical Calculator"<<endl;
    cout<< "What do you want to calculate ?"<<endl;
    cout<< "Choose the number if: charge(1), capacitance(2), current(3), voltage(4) or power(5): ";
    cin>> electric.choice;
    system ("cls");
    do
    {
    if (electric.choice==1)
    {
    cout<< "Please enter the value of current: ";
        cin>>electric.current;
        cout<< "Please enter the value of time: ";
        cin>>electric.time;
        electric.charge= electric.current*electric.time;
        cout<< "Value of charge is: "<<electric.charge<<" C"<<endl;
        outfile<< "Value of charge is: "<<electric.charge<<" C"<<endl;

    }
    else if(electric.choice==2)
    {
        cout<< "Please enter the value of charge: ";
        cin>>electric.charge;
        cout<< "Please enter the value of voltage: ";
        cin>>electric.voltage;
        electric.capacitance= electric.charge/electric.voltage;
        cout<< "The value of capacitance is: "<<electric.capacitance<<" F"<<endl;
        outfile<< "The value of capacitance is: "<<electric.capacitance<<" F"<<endl;
    }
    else if (electric.choice==3)
    {
        cout<< "Please enter the value of power: ";
        cin>>electric.power;
        cout<< "Please enter the value of voltage: ";
        cin>>electric.voltage;
        electric.current= electric.power/electric.voltage;
        cout<< "Value of current is: "<<electric.current<<" A"<<endl;
        outfile<< "Value of current is: "<<electric.current<<" A"<<endl;
    }
    else if(electric.choice==4)
    {
        cout<< "Please enter the value of power: ";
        cin>>electric.power;
        cout<< "Please enter the value of current: ";
        cin>>electric.current;
        electric.voltage= electric.power/electric.current;
        cout<< "Value of voltage is: "<<electric.voltage<<" V"<<endl;
        outfile<< "Value of voltage is: "<<electric.voltage<<" V"<<endl;
    }
    else if(electric.choice==5)
    {
        cout<< "Please enter the value of voltage: ";
        cin>> electric.voltage;
        cout<< "Please enter the value of current: ";
        cin>> electric.current;
        electric.power= electric.voltage*electric.current;
        cout<< "The value of power is: "<<electric.power<<" W"<<endl;
        outfile<< "The value of power is: "<<electric.power<<" W"<<endl;
    }
    }
    while(electric.x==-1);
    {
        cout<< "Thank you"<<endl;
    }
    outfile.close();
}

float calc_perimeter_circle(float rad)
{
    return(2 * 3.14 * rad);
}

float calc_area_circle(float rad)
{
    return (3.14 * rad * rad);
}

float calc_volume_circle(float rad)
{
    return (4/3 * 3.14 * rad * rad * rad);
}

void trigoCalculator()
{
    ofstream outfile;
    outfile.open("Trigo Calculator.txt",fstream::app);
    float PI=3.14259;
    cout<< "What do you want to calculate ?"<<endl;
    cout<< "Choose the number if: sin(1), cos(2), tan(3), cot(4), csc(5), sec(6): ";
    cin>> trigo.choice3;
    system("cls");
    do
    {
        if (trigo.choice3==1)
        {
        cout<< "Please enter the angle: ";
        cin>>trigo.angle;
        trigo.radian= (trigo.angle) * PI/180;
        cout<< "Value in radian is: "<<trigo.radian<<endl;
        cout<< "Value of Sin is: "<<sin (trigo.radian)<<endl;
        outfile<< "The value in radian is: "<<trigo.radian<<endl;
        outfile<< "The value of Sin is: "<<trigo.dsin<<endl;
        }
        else if(trigo.choice3==2)
        {
        cout<< "Please enter the angle: ";
        cin>>trigo.angle;
        trigo.radian= (trigo.angle) * PI/180;
        cout<< "The value in radian is: "<<trigo.radian<<endl;
        trigo.dcos=cos (trigo.radian);
        cout<< "The value of Cos is: "<<trigo.dcos<<endl;
        outfile<< "The value in radian is: "<<trigo.radian<<endl;
        outfile<< "The value of Cos is: "<<trigo.dcos<<endl;
        }
        else if(trigo.choice3==3)
        {
        cout<< "Please enter the angle: ";
        cin>>trigo.angle;
        trigo.radian= (trigo.angle) * PI/180;
        cout<< "The value in radian is: "<<trigo.radian<<endl;
        trigo.dtan=tan (trigo.radian);
        cout<< "The value of Tan is: "<<trigo.dtan<<endl;
        outfile<< "The value in radian is: "<<trigo.radian<<endl;
        outfile<< "The value of Tan is: "<<trigo.dtan<<endl;
        }
        else if(trigo.choice3==4)
        {
        cout<< "Please enter the angle: ";
        cin>>trigo.angle;
        trigo.radian= (trigo.angle) * PI/180;
        cout<< "The value in radian is: "<<trigo.radian<<endl;
        trigo.dcot= 1/tan (trigo.radian);
        cout<< "The value of Cotangent is: "<<trigo.dcot<<endl;
        outfile<< "The value in radian is: "<<trigo.radian<<endl;
        outfile<< "The value of Cotangent is: "<<trigo.dcot<<endl;
        }
        else if(trigo.choice3==5)
        {
        cout<< "Please enter the angle: ";
        cin>>trigo.angle;
        trigo.radian= (trigo.angle) * PI/180;
        cout<< "Value in radian is: "<<trigo.radian<<endl;
        trigo.dcsc= 1/sin (trigo.radian);
        cout<< "Value of Cosecant is: "<<trigo.dcsc<<endl;
        outfile<< "The value in radian is: "<<trigo.radian<<endl;
        outfile<< "The value of Cosecant is: "<<trigo.dcsc<<endl;
        }
        else if(trigo.choice3==6)
        {
        cout<< "Please enter the angle: ";
        cin>>trigo.angle;
        trigo.radian= (trigo.angle) * PI/180;
        cout<< "Value in radian is: "<<trigo.radian<<endl;
        trigo.dsec= 1/cos (trigo.radian);
        cout<< "Value of Secant is: "<<trigo.dsec<<endl;
        outfile<< "The value in radian is: "<<trigo.radian<<endl;
        outfile<< "The value of Secant is: "<<trigo.dsec<<endl;
        }
    }
     while(trigo.y!=0);
    {
        cout<< "Thank you"<<endl;
    }
    outfile.close();
}


# data[].attributes.body
Group: ZEUS
ABD RAHMAN AUF
MUHAMMAD AINUL IMRAN
MUHAMMAD FARIZ AIMAN

# data[].attributes.body
ABD RAHMAN AUF
MUHAMMAD AINUL IMRAN
MUHAMMAD FARIZ AIMAN
MINI PROJECT CODING

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <windows.h>
#include <fstream>

using namespace std;
void basicCalc(int &);
void matrices(int &);
void Trigo(int &);
void Electrical(int &);
void Quadratic(int &);
void cirTriangle(int &);
void Convert(int &);

const double Pi = 3.141592654;

struct electro
{
    float cas, capacitance, arus, voltan, kuasa, rintangan, masa;
    int pilih;

};


int main()
{
    int calc=0,A,B,C,D,E,F,G ;

    while (calc!=-1)
    {
    cout<<" ******************************************************************************************************"<<endl;
    cout<<" *"<<" 1. Addition, Subtraction, Multiplication and Division Operations of Scalar Values. "<<setw(17)<<"*"<< endl ;
    cout<<" *"<<" 2. Addition, Subtraction and Multiplication of Matrices." << setw(44)<<"*"<< endl ;
    cout<<" *"<<" 3. Conversion Between Binary Values, Hexadecimal Values and Decimal Values."<<setw(25)<<"*" << endl ;
    cout<<" *"<<" 4. Trigonometric Operations: Finding Cosine, Sine, Tangent, Cotangent, Cosecant and Secant."<<setw(9)<<"*"<< endl ;
    cout<<" *"<<" 5. Compute Electrical Charge, Capacitance, Current, Voltages and Power."<<setw(29)<<"*" << endl ;
    cout<<" *"<<" 6. Compute Perimeter/Circumference, Area and Volume of Rectangles and Circles."<<setw(22)<<"*"<< endl ;
    cout<<" *"<<" 7. Quadratic Equations."<<setw(77)<<"*"<< endl ;
    cout<<" *"<<" 8. Enter -1 to quit." << endl;
    cout<<" ******************************************************************************************************"<<endl;



    cout<<" Please Enter Your Choice: ";
    cin>>calc;
    cout << endl;



    switch(calc)
    {
    case 1:
        basicCalc(A);
        break;
    case 2:
        matrices(B);
        break;
    case 3:
        Convert(C);
        break;
    case 4:
        Trigo(D);
        break;
    case 5:
        Electrical(E);
        break;
    case 6 :
        cirTriangle(F);
        break;
    case 7:
        Quadratic(G);
        break;

    default:
        {
            cout << "Invalid Choice. Thank You"<< endl;

        }
    }
    }



}


void basicCalc(int &num)
{
    int num1,num2,result,Op;
    ofstream dataFile;
    dataFile.open("basicCalc.txt" , fstream::app);

    cout << " 1.Addition" << endl << " 2.Subtraction" << endl
    << " 3.Multiplication" << endl << " 4.Division"<<endl;
    cout << " Please Enter Your Choice: ";
    cin >> Op;

    dataFile.open("basicCalc.txt" , fstream::app);
    cout << " Insert integer 1: ";
    cin >> num1;
    dataFile << "integer 1: " << num1 << endl;


    cout << " Insert integer 2: ";
    cin >> num2;
    dataFile << "integer 1: " << num2 << endl;
    cout << endl;

    if (Op==1)
    {
       result=num1+num2;
       cout<<" The result: "<<num1<<"+"<<num2<<"="<<result << endl<<endl;
       dataFile << "result addition: " << result << endl << endl;
    }

     else if (Op==2)
    {
       result=num1-num2;
       cout<<" The result: "<<num1<<"-"<<num2<<"="<<result<<endl<<endl;
       dataFile<<"result subtraction: "<< result<<endl<<endl;
    }

     else if (Op==3)
    {
       result=num1*num2;
       cout<<" The result: "<<num1<<"x"<<num2<<"="<<result<<endl<<endl;
       dataFile<<"result multiplication: "<< result<<endl<<endl;
    }

     else if (Op==4)
    {
       result=num1/num2;
       cout<<" The result: "<<num1<<"/"<<num2<<"="<<result<<endl<<endl;
       dataFile<<"result division: "<< result<<endl<<endl;
    }

    if(Op >= 5)
    {
        cout<<"Invalid Choice. Thank You."<<endl<<endl;
    }

}

void matrices(int &matrix)
{
    int x,a,b,rw,col, first[5][5], second[5][5], sum[5][5], subtract[5][5], multiply[5][5];
    ofstream dataFile;
    dataFile.open("matrices.txt" , fstream::app);


    cout << " This program will calculate matrices" << endl;
    cout << " Please enter the number of rows and columns of matrix :" << endl;
    cin >> a >> b;
    dataFile << endl << "a: " << a << "\t" << "b: " << b << endl;

    cout << endl;
    cout << " Please enter the 1st element of matrix:" << endl;
    for(rw=0;rw<a;rw++)
    {
        for(col=0;col<b;col++)
        {
            cin >>first[rw][col];
            dataFile << "First element of matrices: " << first [rw][col] << endl ; // do row first then column
        }
    }
    cout << endl;
    cout << " Please enter the 2nd element of matrix:" <<endl;
    for(rw=0;rw<a;rw++)
    {
        for(col=0;col<b;col++)
        {
            cin >> second[rw][col];
            dataFile << "Second element of matrices: " << second [rw][col] << endl ;
        }
    }
    cout << endl;
    cout << " Please choose your type of calculation" << endl;
    cout << " 1.Addition" << endl << " 2.Subtraction" << endl << " 3.Mutiplication" << endl;
    cout << " Enter your choice: ";
    cin >> x;
    cout << endl;

    for(rw=0;rw<a;rw++)
            {
                for(col=0;col<b;col++)
                {
                    sum[rw][col] = first [rw][col] + second[rw][col];
                    subtract[rw][col] = first [rw][col] - second[rw][col];
                    multiply[rw][col] = multiply[rw][col] + first [rw][col] * second[rw][col];

                }
            }
    switch(x)
    {
        case 1:
            cout << "The value for sum of entered matrices: " << endl;
            for(rw=0;rw<a;rw++)
            {
                for(col=0;col<b;col++)
                {
                    cout << sum[rw][col] ;
                    dataFile << "The value for addition of enterd matrices: " << sum[rw][col] << endl<<endl ;
                    cout << endl;
                }
            }
            break;

        case 2:
            cout << "The value for subtraction of entered matrices: " << endl;
            for(rw=0;rw<a;rw++)
            {
                for(col=0;col<b;col++)
                {
                    cout << subtract[rw][col] ;
                    dataFile << "The value for subtraction of entered matrices: " << subtract[rw][col] << endl<<endl ;
                    cout << endl;
                }
            }
            break;

        case 3:
            cout << " The value for multiplication of entered matrices: " << endl;
            for(rw=0;rw<a;rw++)
            {
                for(col=0;col<b;col++)
                {
                    cout << multiply[rw][col] ;
                    dataFile << " The value for multiplication of entered matrices: " << multiply[rw][col] << endl<<endl ;
                    cout << endl;
                }
            }
            break;

        default:
            {
                cout << "Invalid Choice. Thank You."<< endl<<endl;

            }
    }

}

void Trigo(int &trigo)
{
    double degree, radian;
    int choice;
    ofstream dataFile;
    dataFile.open("Trigo.txt" , fstream::app);

    cout << " Please choose your operation." << endl;
    cout << " 1.Cosine" << endl << " 2.Sine" << endl << " 3.Tangent" << endl << " 4.Cotangent"
    << endl << " 5.Cosecant" << endl << " 6.Secant" << endl;
    cout << " Please Enter Your Choice: ";
    cin >> choice;
    cout << endl;
    cout << " Please enter the value of angle in degree: ";
    cin >> degree;
    dataFile << "Angle in degree: " << degree << endl;


    radian = (degree * Pi/180) ;

    if(choice == 1)
    {
        cout<<" Cos (degree)= " << setprecision(5) << cos (radian) << endl<<endl;
        dataFile << "Cos (degree): " << cos(radian) << endl << endl;
    }

    else if(choice == 2)
    {
        cout<<" Sin (degree)=" << setprecision(3) << sin (radian) << endl<<endl ;
        dataFile << "Sin (degree): " << sin(radian) << endl << endl;
    }

    else if(choice == 3)
    {
        cout<<" Tan (degree)=" << setprecision(3) << tan (radian) << endl<<endl ;
        dataFile << "Tan (degree): " << tan(radian) << endl << endl;
    }

    else if(choice == 4)
    {
        cout<<" Cot (degree)=" << setprecision(6) << 1/tan (radian) << endl<<endl; //cot = 1/tan
        dataFile << "Cot (degree): " << 1/tan (radian) << endl << endl;
    }

    else if(choice == 5)
    {
        cout<<" Csc (degree)=" << setprecision(6) << 1/sin (radian) << endl<<endl;// csc = 1/ sin
        dataFile << "Csc (degree): " << 1/sin (radian) << endl << endl;
    }

    else if (choice == 6)
    {
         cout<<" Sec (degree)=" << setprecision(6) << 1/cos (radian) << endl<<endl;// sec = 1/cos
         dataFile << "Sec (degree): " << 1/cos (radian) << endl << endl;
    }

    if (choice >=7)
    {
        cout << "Invalid Choice. Thank You."<<endl;
    }

}

void Electrical(int &elec)
{
    electro electric;
    ofstream dataFile;
    dataFile.open("Electrical.txt" , fstream::app);

    cout << " Choose operation:" << endl;
    cout << " 1.Voltage" << endl;
    cout << " 2.Current" << endl;
    cout << " 3.Charge" << endl;
    cout << " 4.Capacitance" << endl;
    cout << " 5.Power" <<endl;
    cout << " Please Enter Your choice: ";
    cin>>electric.pilih;

    if (electric.pilih == 1) //voltage
    {
        cout << " Enter resistance value: ";
        cin >> electric.rintangan;
        dataFile << " Enter resistance value: "<<electric.rintangan<<endl;


        cout << " Enter current value: ";
        cin >> electric.arus;
        dataFile << " Enter current value: "<<electric.arus<<endl;



        electric.voltan = electric.arus*electric.rintangan;
        cout << " The voltage value is: " << electric.voltan << " V"<<endl<<endl;
        dataFile << " The Voltage Value is: " << electric.voltan << "V"<< endl<<endl;
    }

    else if (electric.pilih == 2) //current
    {
        cout << " Enter resistance value: ";
        cin >> electric.rintangan;
        dataFile << " Enter resistance value: "<<electric.rintangan<<endl;

        cout << " Enter voltage value: ";
        cin >> electric.voltan;
        dataFile << " Enter voltage value: "<<electric.voltan<<endl;

        electric.arus = electric.voltan/electric.rintangan;
        cout << " The current value is: " << electric.arus << " A"<<endl<<endl;
        dataFile << " Enter current is: "<<electric.arus<<" A"<<endl;

    }

    else if (electric.pilih == 3) //cas
    {
        cout << " Enter time period in seconds: ";
        cin >> electric.masa;
        dataFile << " Enter time period in seconds: "<<electric.masa<<endl;

        cout << " Enter current value: ";
        cin >> electric.arus;
        dataFile << " Enter current value: "<<electric.arus<<endl;

        electric.cas = electric.arus*electric.masa;
        cout << " The charge value is: " << electric.cas << " C"<<endl<<endl;
        dataFile << " Enter resistance value: "<<electric.cas<<"C"<<endl<<endl;

    }

     else if (electric.pilih == 4)// capacitance
    {
        cout << " Enter charge value: ";
        cin >> electric.cas;
        dataFile << " Enter charge value: "<<electric.cas<<endl;

        cout << " Enter voltage value: ";
        cin >> electric.voltan;
        dataFile << " Enter voltage value: "<<electric.voltan<<endl;

        electric.capacitance = electric.cas/electric.voltan;
        cout << " The capacitance value is: " <<electric.capacitance << " F"<<endl<<endl;
        dataFile << " The capacitance value is: "<<electric.capacitance<<"F"<<endl<<endl;

    }

     else if (electric.pilih == 5)//kuasa
    {
        cout << " Enter voltage value: ";
        cin >> electric.voltan;
        dataFile << " Enter voltage value: "<<electric.voltan<<endl;

        cout << " Enter current value: ";
        cin >> electric.arus;
        dataFile << " Enter current value: "<<electric.arus<<endl;

        electric.kuasa = electric.voltan*electric.arus;
        cout << " The power value is: " << electric.kuasa << " W"<<endl<<endl;
        dataFile << " The power value is: "<<electric.kuasa<<"W"<<endl;
    }

    if (electric.pilih>=6)
    {
        cout << " Invalid Choice. Thank You "<<endl<<endl;
    }
}

void cirTriangle(int &cirtri)
{
    int x;
    float a, b, base, height, width, radius, perimeter,volume, circumference, area ;
    ofstream dataFile;
    dataFile.open("cirTriangle.txt" , fstream::app);


    cout << " Choose your operation: "<<endl<<" 1. Area of rectangle"<<endl
    <<" 2. Area of Circle"<<endl<<" 3. Perimeter of rectangle"<<endl
    <<" 4. Circumference of Circle"<<endl<<" 5. Volume of rectangle"<<endl<<" 6. Volume of Sphere"<< endl;
    cout<<" Please enter your choice: ";
    cin>>x;

    switch(x)
    {
        case 1:
            cout<<" Enter base and height of rectangle: ";
            cin>>base>>height;
            dataFile<<"Base: "<<base<<"\t"<<"Height: "<<height<<endl;

            area = base*height;
            cout<<" The area of rectangle is: "<<area<<endl<<endl;
            dataFile<<" Area of rectangle: "<< area<<endl<<endl;
            break;

        case 2:
            cout<<" Please enter the radius of the circle: ";
            cin>>radius;
            dataFile<<"Radius: "<< radius<<endl;

            area = Pi*(radius*radius);
            cout <<" The area of circle is: "<< area<<endl<<endl;
             dataFile<<"Area of circle: "<< area<<endl<<endl;
            break;

        case 3:
            cout <<" Please enter the value a and b: ";
            cin >> a >> b ;
            dataFile<<"A: "<<a<<"\t"<<"B: "<<b<<endl;

            perimeter = (2*a)+(2*b);
            cout << " The perimeter of the rectangle: " << perimeter<<endl<<endl;
            dataFile<<"Perimeter of rectangle: "<< perimeter <<endl<<endl;
            break;

        case 4:
            cout << " Please enter the radius of the circle: ";
            cin >> radius;
            dataFile<<"Radius: "<<radius<<endl;

            circumference = 2* Pi * radius;
            cout << " The circumference of circle is: " << circumference<<endl<<endl ;
            dataFile<<"Circumference of circle: "<< circumference<<endl<<endl;
            break;

        case 5:
            cout << " Please enter the value of base, height and width: ";
            cin >> base >> height >> width ;
            dataFile<<"Base: "<<base<<"\t"<<"Height: "<<height<<"\t"<<"Width: "<< width <<endl;


            volume =  base * height * width;
            cout << " The volume of rectangle: " << volume<<endl<<endl;
            dataFile<<"Volume of rectangle: "<< volume<<endl<<endl;
            break;

        case 6:
            cout << " Please enter the radius of the sphere: ";
            cin >> radius;
            dataFile<<"Radius: "<<radius<<endl;

            volume = 1.333 *Pi *radius *radius *radius; //1.333 = 4/3
            cout << " The volume of sphere: " << volume<<endl<<endl;
            dataFile<<"Volume of sphere: "<<volume<<endl;
            break;


        default:
            cout<<" Invalid Choice. Thank You."<<endl<<endl;

    }
}

void Quadratic(int &quad)
{
    int a, b, c;
    ofstream dataFile;
    dataFile.open("Quadratic.txt" , fstream::app);

    cout << " Please enter the three value:";
    cin >> a >> b >> c;
    dataFile<<"A: "<<a<<"\t"<<"B: "<<b<<"\t"<<"C: "<<c<< endl;

    cout << " Your quadratic function is: "<<a<<"x^2+"<<b<<"x+"<<c<<endl;

    cout << " Now this program will find its roots.... "<<endl;


    cout <<" Computing roots";
    for (int i=0;i<=5;i++)
    {
       cout<<".";
       Sleep(500);
    }
    cout << endl;
    float p;
    float root1, root2;
    p = pow(b,2)-4*a*c;
    if (p<0)
    {
       cout <<" There is no real root"<<endl<<endl;
       dataFile<<"There is no real root"<<endl<<endl;
    }

    if (p>0)
    {
        cout << " There are two real roots"<<endl;
        root1 = (-b+sqrt(p))/(2*a);
        root2 = (-b-sqrt(p))/(2*a);
        cout << " The roots are : "<<root1<<" and "<<root2<<endl<<endl;
        dataFile<<" Two equal root"<<endl;
        dataFile<<" Root 1: " <<root1<<"\t"<<"Root 2: "<<root2<<endl<<endl;
    }

    if (p==0)
    {
       cout <<" There is one real root"<<endl;
       root1 = (-b+p)/(2*a);
       cout << " The root is : "<<root1<<endl<<endl;
       dataFile<<"Two is one real root"<<endl;
       dataFile<<"Root 1: " <<root1<<endl<<endl;
    }


}


void Convert(int &conv)
{
    int decimal = 0,x,remainder,y=1,sm=0,binary ;
    ofstream dataFile;
    dataFile.open("Convert.txt" , fstream::app);

    cout<<" Choose your operation:"<<endl;
    cout<<" 1. Decimal to Binary "<<endl<<" 2. Decimal to Hexadecimal "<<endl<<" 3. Binary to Decimal "<<endl;
    cout<<" Please Enter Your Choice: ";
    cin>>x;

    switch(x)
    {
        case 1:

            cout<<" Please enter the decimal num:";
            cin>>decimal;
            dataFile<<"Decimal num: "<< decimal<<endl;
            do
            {
                remainder = decimal%2;
                sm = sm + (y*remainder); //repeated loop
                decimal=decimal/2;
                y=y*10;

            }
            while(decimal>0);
            cout<<" The binary num is:"<<sm<<endl<<endl;
            dataFile<<"The Binary num: " <<sm<<endl<<endl;

            break;

        case 2:
            cout << " Please enter decimal num: ";
            cin >> decimal;
            dataFile<<"Decimal num: "<< decimal<<endl;

            cout << " The hexadecimal number for " << decimal << ": " << hex << decimal<<endl<<endl ;
            dataFile<<"The hexadecimal num: "<<hex<<decimal<<endl;
            break;

        case 3:
            	cout<<" Please enter binary num: ";
                cin>>binary;
                dataFile<<"Binary num: "<< binary<<endl;
                while(binary!=0)
                {
                    remainder = binary % 10;
                    decimal = decimal + remainder*y;
                    y = y*2;
                    binary = binary /10;            //repeat until the binary equal to 0

                }
                cout<<" The decimal num = "<<decimal<<endl<<endl;
                dataFile<<"The decimal num: "<< decimal<<endl;

    }
}

# data[].attributes.body
c++ codes

# data[].attributes.body
TurnItIn report

# data[].attributes.body
report

# data[].attributes.body
Group X: Flowchart

# data[].attributes.body
Group X: Report Turnitin

# data[].attributes.body
Group X: Report