# 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.body
report

# data[].attributes.body
coding

# 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
Mohammad Izzuan bin Ishak
Muhammed Azril bin Mustapha

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

# 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.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.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.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.body
Flowchart B and C in different Microsoft Word because in landscape layout

# 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: MVP
Muhmmad afiq
Muhammad haziq
Muhammad saifuddien

# data[].attributes.body
c++ codes

# 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
TurnItIn report

# data[].attributes.body
Group: ZEUS
ABD RAHMAN AUF
MUHAMMAD AINUL IMRAN
MUHAMMAD FARIZ AIMAN

# data[].attributes.body
report

# data[].attributes.body
Group X: Flowchart

# data[].attributes.body
Group X: Report Turnitin

# data[].attributes.body
Group X: Report