MAIN.CPP FILE OF SCIENTIFIC CALCULATOR

/*MAIN.CPP*/
#include <iostream>
using namespace std;
#include <math.h>
#include <iomanip>
#include "calculator.h"
int main()
{
     while(1)
{
 cout<<"CHOICE 1 addition"<<endl;
 cout<<"CHOICE 2 subtraction"<<endl;
 cout<<"CHOICE 3 division"<<endl;
 cout<<"CHOICE 4 multiplication"<<endl;
 cout<<"CHOICE 5 fraction"<<endl;
 cout<<"CHOICE 6 conversion of degree to radian"<<endl;
 cout<<"CHOICE 7 trigonometric functions"<<endl;
 cout<<"CHOICE 8 logarithm"<<endl;
 cout<<"CHOICE 9 exponential"<<endl;
 cout<<"CHOICE 10 power"<<endl;
 cout<<"CHOICE 11 log10"<<endl;
 cout<<"CHOICE 12 matrix addition"<<endl;
 cout<<"CHOICE 13 matrix subtraction"<<endl;
 cout<<"CHOICE 14 matrix multiplication"<<endl;
 cout<<"CHOICE 15 modulus"<<endl;
 cout<<"CHOICE 16 percentage"<<endl;
 cout<<"CHOICE 17 binary to decimal"<<endl;
 cout<<"CHOICE 18 binary to hexadecimal"<<endl;
 cout<<"CHOICE 19 decimal to binary"<<endl;
 cout<<"CHOICE 20 area finding"<<endl;
 cout<<"CHOICE 21 volume finding"<<endl;
 cout<<"CHOICE 22 factorial"<<endl;
 cout<<"CHOICE 23 permutation"<<endl;
 cout<<"CHOICE 24 combination"<<endl;
 cout<<"CHOICE 25 integrals"<<endl;
 int choice;
 cout<<"Enter your choice: "<<endl;
 cin>>choice;
    ScientificCalculator c;
 if(choice==1)
  {
   c.add();//addition
 }
 else if(choice==2)
 {
 c.sub();//subtraction
 }
 else if(choice==3)
 {
 c.divide();//division
 }
 else if(choice==4)
  {
   c.multiply();//multiplication
 }
 else if(choice==5)
  {
   c.fraction();//fraction
 }
 else if(choice==6)
 {
 c.radians();//conversion of degree to radian
 }
 else if(choice==7)
  {
   c.trigonometry();//includes sin cos tan trigonometric functions
 }
 else if(choice==8)
  {
   c.logarithm();//logarithm
 }
 else if(choice==9)
  {
   c.exponential();//exponential
 }
 else if(choice==10)
  {
   c.power();//power
 }
 else if(choice==11)
  {
   c.logarithm10();//log10
 }
 else if(choice==12)
  {
   int r,c,a[100][100],b[100][100],sum[100][100],i,j;
    cout << "Enter number of rows (between 1 and 100): ";
    cin >> r;
    cout << "Enter number of columns (between 1 and 100): ";
    cin >> c;
    cout << endl << "Enter elements of 1st matrix: " << endl;
/* Storing elements of first matrix entered by user. */
    for(i=0;i<r;++i)
       for(j=0;j<c;++j)
       {
           cout << "Enter element a" << i+1 << j+1 << " : ";
           cin >> a[i][j];
       }
/* Storing elements of second matrix entered by user. */
    cout << endl << "Enter elements of 2nd matrix: " << endl;
    for(i=0;i<r;++i)
       for(j=0;j<c;++j)
       {
           cout << "Enter element b" << i+1 << j+1 << " : ";
           cin >> b[i][j];
       }
/*Adding Two matrices */
   for(i=0;i<r;++i)
       for(j=0;j<c;++j)
           sum[i][j]=a[i][j]+b[i][j];
/* Displaying the resultant sum matrix. */
    cout << endl << "Sum of two matrix is: " << endl;
    for(i=0;i<r;++i)
       for(j=0;j<c;++j)
       {
           cout << sum[i][j] << "  ";
           if(j==c-1)
               cout << endl;
       }
 }
 else if(choice==13)
  {
   cout<<"   WELCOME TO THE MATRIX ADDITION PORTION."<<endl;
   cout<<endl;
   int a, b, c, d, first[10][10], second[10][10], sum[10][10];
   cout<<"Enter the number of rows and columns of matrix ";
   cin>>a>>b;
   cout<<"    Enter the elements of first matrix: "<<endl;
   for(c = 0 ; c < a ; c++)
      for(d = 0 ; d < b ; d++)
         cin >> first[c][d];
   cout<<"    Enter the elements of second matrix: ";
   for(c = 0 ; c < a ;c++)
      for(d = 0 ; d < b ; d++)
            cin>>second[c][d];
   for(c = 0 ; c < a ; c++)
      for(d = 0 ; d < b ; d++)
         sum[c][d] = first[c][d] + second[c][d];
   cout<<"  Sum of entered matrices: ";
   for(c = 0; c < a ; c++)
   {
      for(d = 0; d < b; d++)
         cout<<sum[c][d]<<"\t";
      cout<<endl;
   }
 }
 else if(choice==14)
  {
   c.matrix_multiplication();//matrix multiplication
 }
 else if(choice==15)
  {
   c.modulus();
 }
 else if(choice==16)
  {
   c.percentage();//percentage
 }
 else if(choice==17)
  {
   c.decimal();//binary to decimal
 }
 else if(choice==18)
  {
   c.hexadecimal();//binary to hexadecimal
 }
 else if(choice==19)
  {
   c.binary();//decimal to binary
 }
 else if(choice==20)
  {
   c.area();//area finding
 }
 else if(choice==21)
  {
   c.volume();//volume finding
 }
 else if(choice==22)
  {
   c.factorial();//factorial of a number
 }
 else if(choice==23)
  {
   c.permutation();//permutation by the help of the arrays
 }
 else if(choice==24)
  {
   c.combination();//finding the combination
 }
 else if(choice==25)
  {
   c.integration();//by the help of
 }
 else
    {
  cout<<"INVALID CHOICE."<<endl;
    }
}
 return 0;
 }

Comments

Popular posts from this blog

Scientific Calculator Project Proposal