Important alert: (current site time 8/30/2014 1:52:51 PM EDT)
 

VB icon

Scientific Calculator

Email
Submitted on: 1/23/2012 1:24:06 PM
By: Bhaskar Jyoti Borah  
Level: Beginner
User Rating: By 1 Users
Compatibility: C++ (general)
Views: 10754
author picture
(About the author)
 
     The prepared project is based on a scientific calculator. This program is developed in Turbo c++ compiler. Object oriented programming concept is used in this Scientific Calculator. This project has been prepared by using simple library functions like clrscr(), gotoxy(), getch() etc. and loops like if-else, while and do while loops. Effort is made to make this Scientific Calculator readable, efficient, reliable, meaningful, portable, and user friendly. In this calculator 21 functions are included.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Scientific Calculator
// Description:The prepared project is based on a scientific calculator. This program is developed in Turbo c++ compiler. Object oriented programming concept is used in this Scientific Calculator. This project has been prepared by using simple library functions like clrscr(), gotoxy(), getch() etc. and loops like if-else, while and do while loops.
	
Effort is made to make this Scientific Calculator readable, efficient, reliable, meaningful, portable, and user friendly. In this calculator 21 functions are included. 
// By: Bhaskar Jyoti Borah
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=13744&lngWId=3//for details.//**************************************

//calculator.
//By Bhaskar
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<math.h>
class cal{
private:
	double n1,n2,res,sum,mult;	//declaration of private variable(s) and function(s)
	double factr(double);
public:
	void wlcm();	//declaration of public functions
	void bye();
	void add();
	void sub();
	void npr();
	void box(int,int,int,int,char,char);
	void mul();
	void div();
	void sqroot();
	void square();
	void ncr();
	void tan_fun();
	void sinin();
	void power();
	void cosin();
	void tanin();
	void menu();
	void factrl();
	void cos_fun();
	void sin_fun();
	void cube();
	void inverse();
	void log_fun();
	void ln_fun();
}; cal c;
void cal::wlcm()	//function for welcome screen
{
	cout<<"\n\n\n\n\n\t%% %%";
	cout<<"\n\t%% %% %%%%%%% %% %%%%%% %%%%%% %%%%%%%% %%%%%%%";
	cout<<"\n\t%% %% %% %% %% %% %% %% %%% %% %% ";
	cout<<"\n\t%% %% %% %%%%%%% %% %% %% %% %%% %% %%%%% ";
	cout<<"\n\t%% %% %% %% %% %% %% %% %%%% %% ";
	cout<<"\n\t%%%%%%%%%% %%%%%%% %%%%%%% %%%%%% %%%%%% %%%% %%%%%%%";
	cout<<"\n\n\n\n\t\t\t$$$$$$$$ $$$$$ ";
	cout<<" \n\t\t\t$$ $$ ";
	cout<<" \n\t\t\t$$ $$ ";
	cout<<" \n\t\t\t$$ $$$$$ ";
	cout<<"\n\n\n\t\t\t ";
	char arr1[20]={'C','O','M','P','U','T','E','R',' ','P','R','O','J','E','C','T'};
	for(int i=0;i<17;i++)
	{
		cout<<arr1[i]<<" ";
		delay(200);
	}
	cout<<"\n\n\n\t\t\t";
	char arr2[20]={'C','A','L','C','U','L','A','T','O','R'};
	for(i=0;i<10;i++)
	{
		cout<<arr2[i]<<" ";
		delay(200);
	}
	cout<<"\n\n\n\t\t\t\tB Y :-\n\n";
	cout<<"\n\n\t\t\t* Bhaskar Jyoti Borah XII ";
	cout<<"\n\n\n\n\t\t\tPress any key to continue : ";
	getch();
}
void cal::bye()		//function for ending screen
{
	clrscr();
	cout<<"\n\n\n\n\n\t\t$$$$$$$$ $$$$$$$$$$$$$ $$ $$ ";
	cout<<"\n\t\t$$ $$$$ $$$$ $$$ $$ $$ $$ ";
	cout<<"\n\t\t$$ $$$$$$$ $$$$$$$ $$ $ $$ $$$";
	cout<<"\n\t\t$$ $$$$ $$$$ $$ $$$ $$ $$ ";
	cout<<"\n\t\t$$ $$$$ $$$$ $$$$ $$ $$ ";
	cout<<"\n\n\n\n\n\t\t$$$$$$$$$$$$$$ ";
	cout<<"\n\t\t$$ $$$$$$$$$$ ";
	cout<<"\n\t\t $$ $$$$$$$$ ";
	cout<<"\n\t\t $$ $$$$$$$$ ";
	cout<<"\n\t\t $$$$$$$$ $$$$$$";
	delay(3000);
}
void cal::add()		//function for addition
{
	clrscr();
	sum=0;
	int x=1;
	char ch='y';
	while(ch=='y'||ch=='Y')
	{
		clrscr();
		gotoxy(9,5);
		cout<< "A D D I T I O N : ";
		cout<<"\n\t_________________";
		if(x==1)
			cout<<"\n\n\n\n\n\tEnter the 1st number : ";
		else if(x==2)
			cout<<"\n\n\n\n\n\tEnter the 2nd number : ";
		else if(x==3)
			cout<<"\n\n\n\n\n\tEnter the 3rd number : ";
		else
			cout<<"\n\n\n\n\n\tEnter the "<<x<<"th number : ";
		c.box(2,2,55,39,'#','*');
		c.box(32,9,20,4,'*','*');
		gotoxy(34,11);
		cin>>n1;
		sum=sum+n1;
		if(x>=2)
		{
			cout<<"\n\n\n\n\n\n\n\n\tEnter more number ? (y/n) : ";
			c.box(37,18,6,4,'*','*');
			c.box(2,2,55,39,'#','*');
			gotoxy(39,20);
			go1:
			cin>>ch;
		}
		x++;
	}
	cout<<"\n\n\n\n\n\n\n\tAddition result : ";
	c.box(27,26,25,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(29,28);
	cout<<sum;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::sub()		//function for subtraction
{
	clrscr();
	gotoxy(9,5);
	cout<<"S U B T R A C T I O N : ";
	cout<<"\n\t_______________________";
	cout<<"\n\n\n\n\n\tEnter the 1st number : ";
	c.box(2,2,55,39,'#','*');
	c.box(32,9,20,4,'*','*');
	gotoxy(34,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\tEnter the 2nd number : ";
	c.box(2,2,55,39,'#','*');
	c.box(32,17,20,4,'*','*');
	gotoxy(34,19);
	cin>>n2;
	res=n1-n2;
	cout<<"\n\n\n\n\n\n\n\n\tSubtraction result : ";
	c.box(30,26,20,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(32,28);
	cout<<res;
	cout<<"\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::mul()		//function for multiplication
{
	clrscr();
	mult=1;
	int x=1;
	char ch='y';
	while(ch=='y'||ch=='Y')
	{
		clrscr();
		gotoxy(9,5);
		cout<<"M U L T I P L I C A T I O N : ";
		cout<<"\n\t_____________________________";
		if(x==1)
			cout<<"\n\n\n\n\n\tEnter the 1st number : ";
		else if(x==2)
			cout<<"\n\n\n\n\n\tEnter the 2nd number : ";
		else if(x==3)
			cout<<"\n\n\n\n\n\tEnter the 3rd number : ";
		else
			cout<<"\n\n\n\n\n\tEnter the "<<x<<"th number : ";
		c.box(2,2,58,39,'#','*');
		c.box(32,9,20,4,'*','*');
		gotoxy(34,11);
		cin>>n1;
		mult=mult*n1;
		if(x>=2)
		{
			cout<<"\n\n\n\n\n\n\n\n\tEnter more number ? (y/n) : ";
			c.box(37,18,6,4,'*','*');
			c.box(2,2,58,39,'#','*');
			gotoxy(39,20);
			go1:
			cin>>ch;
		}
		x++;
	}
	cout<<"\n\n\n\n\n\n\n\tMultiplication result : ";
	c.box(33,26,25,4,'*','*');
	c.box(2,2,58,39,'#','*');
	gotoxy(35,28);
	cout<<mult;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,58,39,'#','*');
}
void cal::div()		//function for division
{
	clrscr();
	gotoxy(9,5);
	cout<<"D I V I S I O N : ";
	cout<<"\n\t_________________";
	cout<<"\n\n\n\n\n\tEnter the 1st number : ";
	c.box(2,2,55,39,'#','*');
	c.box(32,9,20,4,'*','*');
	gotoxy(34,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\tEnter the 2nd number : ";
	c.box(2,2,55,39,'#','*');
	c.box(32,17,20,4,'*','*');
	gotoxy(34,19);
	cin>>n2;
	res=n1/n2;
	cout<<"\n\n\n\n\n\n\n\n\tDivision result : ";
	c.box(27,26,20,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(29,28);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::sqroot()	//function for square root
{
	clrscr();
	gotoxy(9,5);
	cout<<"S Q U A R E R O O T : ";
	cout<<"\n\t______________________";
	cout<<"\n\n\n\n\n\tEnter the number : ";
	c.box(2,2,55,39,'#','*');
	c.box(28,9,20,4,'*','*');
	gotoxy(30,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\n\tSquare root : ";
	c.box(23,18,20,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(25,20);
	cout<<sqrt(n1);
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::square()	//function for square
{
	clrscr();
	gotoxy(9,5);
	cout<<"S Q U A R E : ";
	cout<<"\n\t_____________";
	cout<<"\n\n\n\n\n\tEnter the number : ";
	c.box(2,2,55,39,'#','*');
	c.box(28,9,20,4,'*','*');
	gotoxy(30,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\n\tSquare : ";
	c.box(18,18,20,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,20);
	cout<<pow(n1,2);
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::power()	//function for power
{
	clrscr();
	gotoxy(9,5);
	cout<<"P O W E R : ";
	cout<<"\n\t___________";
	cout<<"\n\n\n\n\n\tEnter the number : ";
	c.box(2,2,55,39,'#','*');
	c.box(28,9,20,4,'*','*');
	gotoxy(30,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\tEnter the power : ";
	c.box(2,2,55,39,'#','*');
	c.box(27,17,10,4,'*','*');
	gotoxy(29,19);
	cin>>n2;
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,26,25,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,28);
	cout<<pow(n1,n2);
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::factrl()	//function for factorial
{
	clrscr();
	gotoxy(9,5);
	cout<<"F A C T O R I A L : ";
	cout<<"\n\t___________________";
	cout<<"\n\n\n\n\n\tEnter the integer : ";
	c.box(2,2,55,39,'#','*');
	c.box(29,9,20,4,'*','*');
	gotoxy(31,11);
	cin>>n1;
	if(n1<0)
		{
		cout<<"\n\n\n\n\n\n\tSyntax error.\a";
		cout<<"\n\n\n\n\n\tPress any key to goto the main menu. ";
		}
	else
		{
			if(n1==1||n1==0)
				res=1;
			else
				res=factr(n1);
			cout<<"\n\n\n\n\n\n\tFactorial : ";
			c.box(21,16,25,4,'*','*');
			c.box(2,2,55,39,'#','*');
			gotoxy(23,18);
			cout<<res;
			cout<<"\n\n\n\n\n\tPress any key to goto the main menu. ";
			c.box(2,2,55,39,'#','*');
		}
}
double cal::factr(double p)	//function for determining factorial
{
	if(p>1)
	p=p*factr(p-1);
	return(p);
}
void cal::ncr()		//function for nCr
{
	clrscr();
	gotoxy(9,5);
	cout<<"n C r : ";
	cout<<"\n\t_______";
	cout<<"\n\n\n\n\n\tValue of 'n' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,20,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\tValue of 'r' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,17,20,4,'*','*');
	gotoxy(26,19);
	cin>>n2;
	if(n1<0 || n2<0 || n1<n2)
	{
		cout<<"\n\n\n\n\n\n\tSyntax error.";
		cout<<"\n\n\n\tPress any key to goto the main menu.";
		c.box(2,2,55,39,'#','*');
		cout<<"\a";
	}
	else
	{
		if(n1==0 && n2==0)
			res=1;
		else if(n1>0 && n2==0)
			res=1;
		else if(n1==n2)
			res=1;
		else
			res=factr(n1)/(factr(n2)*factr(n1-n2));
		cout<<"\n\n\n\n\n\n\tResult : ";
		c.box(18,24,20,4,'*','*');
		c.box(2,2,55,39,'#','*');
		gotoxy(20,26);
		cout<<res;
		cout<<"\n\n\n\n\n\tPress any key to go to the main menu. ";
		c.box(2,2,55,39,'#','*');
	}
}
void cal::npr()		//function for nPr
{
	clrscr();
	gotoxy(9,5);
	cout<<"n P r : ";
	cout<<"\n\t_______";
	cout<<"\n\n\n\n\n\tValue of 'n' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,20,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\tValue of 'r' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,17,20,4,'*','*');
	gotoxy(26,19);
	cin>>n2;
	if(n1<0 || n2<0 || n1<n2)
	{
		cout<<"\n\n\n\n\n\n\tSyntax error.";
		cout<<"\n\n\n\tPress any key to goto the main menu.";
		c.box(2,2,55,39,'#','*');
		cout<<"\a";
	}
	else
	{
		if(n1==0 && n2==0)
			res=1;
		else if(n1>0 && n2==0)
			res=1;
		else if(n1==n2)
			res=factr(n1);
		else
			res=factr(n1)/factr(n1-n2);
		cout<<"\n\n\n\n\n\n\tResult : ";
		c.box(18,24,20,4,'*','*');
		c.box(2,2,55,39,'#','*');
		gotoxy(20,26);
		cout<<res;
		cout<<"\n\n\n\n\n\tPress any key to go to the main menu. ";
		c.box(2,2,55,39,'#','*');
	}
}
void cal::cube()	//function for cube
{
	clrscr();
	gotoxy(9,5);
	cout<<"C U B E : ";
	cout<<"\n\t_________";
	cout<<"\n\n\n\n\n\tEnter the number : ";
	c.box(2,2,55,39,'#','*');
	c.box(28,9,20,4,'*','*');
	gotoxy(30,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\n\tCube : ";
	c.box(16,18,20,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(18,20);
	cout<<pow(n1,3);
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::inverse()	//function for inverse
{
	clrscr();
	gotoxy(9,5);
	cout<<"I N V E R S E : ";
	cout<<"\n\t_______________";
	cout<<"\n\n\n\n\n\tEnter the number : ";
	c.box(2,2,55,39,'#','*');
	c.box(28,9,20,4,'*','*');
	gotoxy(30,11);
	cin>>n1;
	cout<<"\n\n\n\n\n\n\n\n\tInverse : ";
	c.box(19,18,20,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(21,20);
	cout<<pow(n1,-1);
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::log_fun()	//function for logarithm( base is = 10 )
{
	clrscr();
	gotoxy(9,4);
	cout<<"L O G A R I T H M : ";
	cout<<"\n\t___________________";
	cout<<"\n\n\t***** log x ***** ";
	cout<<"\n\t 10 ";
	cout<<"\n\t__________________";
	cout<<"\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,11,20,4,'*','*');
	gotoxy(26,13);
	cin>>n1;
	res=log10(n1);
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,20,22,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,22);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::ln_fun()	//function for ln ( base is = e )
{
	clrscr();
	gotoxy(9,5);
	cout<<"***** ln (x) ***** ";
	cout<<"\n\t__________________";
	cout<<"\n\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,20,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	res=log(n1);
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,18,22,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,20);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::sin_fun()	//function for sin
{
	clrscr();
	gotoxy(9,5);
	cout<<"***** sin(x) ***** ";
	cout<<"\n\t__________________";
	cout<<"\n\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,20,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	res=sin(n1*(3.14159265)/180);
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,18,22,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,20);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::cos_fun()	//function for cos
{
	clrscr();
	gotoxy(9,5);
	cout<<"***** cos(x) ***** ";
	cout<<"\n\t__________________";
	cout<<"\n\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,20,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	res=cos(n1*(3.14159265)/180);
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,18,22,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,20);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::tan_fun()	//function for tan
{
	clrscr();
	gotoxy(9,5);
	cout<<"***** tan(x) ***** ";
	cout<<"\n\t__________________";
	cout<<"\n\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,20,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	res=tan(n1*(3.14159265)/180);
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,18,22,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,20);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::sinin()	//function for sin^-1
{
	clrscr();
	gotoxy(9,5);
	cout<<" -1 ";
	cout<<"\n\t***** sin (x) ***** ";
	cout<<"\n\t____________________";
	cout<<"\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,10,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	if((n1>1)||(n1<-1))
	{
		cout<<"\n\n\n\n\n\tSyntax error.";
		cout<<"\n\n\n\tPress any key to go to the main menu.";
		c.box(2,2,55,39,'#','*');
		cout<<"\a";
	}
	else
	{
		res=asin(n1)*180/(3.14159265);
		cout<<"\n\n\n\n\n\n\n\n\tResult : ";
		c.box(18,18,10,4,'*','*');
		c.box(2,2,55,39,'#','*');
		gotoxy(20,20);
		cout<<res;
		cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
		c.box(2,2,55,39,'#','*');
	}
}
void cal::cosin()	//function for cos^-1
{
	clrscr();
	gotoxy(9,5);
	cout<<" -1 ";
	cout<<"\n\t***** cos (x) ***** ";
	cout<<"\n\t____________________";
	cout<<"\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,10,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	if((n1>1)||(n1<-1))
	{
		cout<<"\n\n\n\n\n\tSyntax error.";
		cout<<"\n\n\n\tPress any key to go to the main menu.";
		c.box(2,2,55,39,'#','*');
		cout<<"\a";
	}
	else
	{
		res=acos(n1)*180/(3.14159265);
		cout<<"\n\n\n\n\n\n\n\n\tResult : ";
		c.box(18,18,10,4,'*','*');
		c.box(2,2,55,39,'#','*');
		gotoxy(20,20);
		cout<<res;
		cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
		c.box(2,2,55,39,'#','*');
	}
}
void cal::tanin()	//function for tan^-1
{
	clrscr();
	gotoxy(9,5);
	cout<<" -1 ";
	cout<<"\n\t***** tan (x) ***** ";
	cout<<"\n\t____________________";
	cout<<"\n\n\n\n\tValue of 'x' : ";
	c.box(2,2,55,39,'#','*');
	c.box(24,9,25,4,'*','*');
	gotoxy(26,11);
	cin>>n1;
	res=atan(n1)*180/(3.14159265);
	cout<<"\n\n\n\n\n\n\n\n\tResult : ";
	c.box(18,18,25,4,'*','*');
	c.box(2,2,55,39,'#','*');
	gotoxy(20,20);
	cout<<res;
	cout<<"\n\n\n\n\n\n\tPress any key to go to the main menu. ";
	c.box(2,2,55,39,'#','*');
}
void cal::menu()	//function for displaying and controlling main menu
{
	gotoxy(18,5);
	cout<<"## C A L C U L A T O R ##";
	cout<<"\n\t\t _________________________";
	cout<<"\n\n\n\tMAIN MENU :\n";
	cout<<"\n\t___________";
	cout<<"\n\n\n\t1--Addition \t11--nCr";
	cout<<" \n\n\t2--Subtraction \t12--nPr";
	cout<<" \n\n\t3--Multiplication\t13--Logarithm";
	cout<<" \n\n\t4--Division \t14--ln";
	cout<<" \n\n\t5--Square root { x^(1/2) } \t15--sin(x)";
	cout<<" \n\n\t6--Square ( x^2 )\t16--cos(x)";
	cout<<" \n\n\t7--Cube ( x^3 ) \t17--tan(x)";
	cout<<" \n\n\t8--Inverse ( 1/x ) \t18--sin-1(x)";
	cout<<" \n\n\t9--Power ( x^y )\t19--cos-1(x)";
	cout<<" \n\n\t10--Factorial ( n! )\t20--tan-1(x)";
	cout<<"\n\n\n\t21--EXIT FROM THIS PROGRAM.";
	cout<<"\n\n\t( Select an option from 1 to 21 )";
	cout<<"	 \n\t_________________________________";
	cout<<"\n\n\n\n\tYour choice : ";
}
void cal::box(int a,int b,int c,int d,char ch1,char ch2)	//function for the box used throughout the program
{
	gotoxy(a,b);
	for(int j=1;j<=c;j++)
		cout<<ch1;
	for(j=b+1;j<=(((b+1)+d)-2);j++)
	{
		gotoxy(a,j);
		cout<<ch2;
		gotoxy((a+c-1),j);
		cout<<ch2;
	}
	gotoxy(a,(b+d));
	for(j=1;j<=c;j++)
		cout<<ch1;
}
void main()	//main
{
	int xyx;
	clrscr();
	c.wlcm();
	while(1)
	{
		clrscr();
		c.menu();
		c.box(2,2,59,45,'#','*');
		c.box(23,40,8,4,'*','*');
		gotoxy(25,42);
		cin>>xyx;
		switch(xyx)
		{
		case 1:
			c.add();
			getch();
			break;
		case 2:
			c.sub();
			getch();
			break;
		case 3:
			c.mul();
			getch();
			break;
		case 4:
			c.div();
			getch();
			break;
		case 5:
			c.sqroot();
			getch();
			break;
		case 6:
			c.square();
			getch();
			break;
		case 7:
			c.cube();
			getch();
			break;
		case 8:
			c.inverse();
			getch();
			break;
		case 9:
			c.power();
			getch();
			break;
		case 10:
			c.factrl();
			getch();
			break;
		case 11:
			c.ncr();
			getch();
			break;
		case 12:
			c.npr();
			getch();
			break;
		case 13:
			c.log_fun();
			getch();
			break;
		case 14:
			c.ln_fun();
			getch();
			break;
		case 15:
			c.sin_fun();
			getch();
			break;
		case 16:
			c.cos_fun();
			getch();
			break;
		case 17:
			c.tan_fun();
			getch();
			break;
		case 18:
			c.sinin();
			getch();
			break;
		case 19:
			c.cosin();
			getch();
			break;
		case 20:
			c.tanin();
			getch();
			break;
		case 21:
			c.bye();
			exit(0);
		default:
			cout<<"\a";
		}
	}
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

3/26/2012 9:54:10 PM

thank sir for this program but can i suggest something ,,
i think it would more awesome if every operation has a back to menu option right away while asking the 1st number so that if the user chose the wrong operation he can go back to menu without finishing the equation just to go back again ...
and i think if you can make every function can operate 2 - 3 mathematical operation would be more effecient,,,,, and i know decimal can be use in that scientific calculator but if fractions can be solve too it would be more awesome ..,,

by the way its awesome
(If this comment was disrespectful, please report it.)

 
10/18/2012 12:33:56 AMSopon

Good
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.