# Calculator, Includes Sin, Cos, Tan And Sqaure Root!

Hey, i was just mucking around and improving my code etc and made a calculator, it's not the best calculator in the world, it only can handle 1 or 2 numbers but i think it's good my self :).

4,003 Views

I'm at secondry school.

``````#include <iostream>
#include <conio.h>
#include <math.h>
#include <stdio.h>

using namespace std;

#define PI 3.14159265

int main()
{
system("TITLE My Calculator Program.");
system("COLOR C");

double firstNumber, secondNumber;
double resultSqrt, resultSin, resultCos, resultTan;
char operation, boolSqrt;

cout << " *****************************************" << endl;;
cout << "  Kizzop Productions - Simple Calculator!" << endl;;
cout << " *****************************************\n\n";

cout << "  OPERATORS : +, -, *, /, !, S, C, T" << endl;
cout << " \n";

cout << "  + = ADD\n  - = SUBTRACT\n  * = Multiplication\n  ";
cout << "/ = Division\n  ! = SQAURE ROOT\n  S = SIN\n  ";
cout << "C = COS\n  T = TAN\n";

cout << " \n ************************************************" << endl;
cout << "  NOTE : YOU CAN USE X AND x FOR MULTIPLICATION!" << endl;
cout << " ************************************************\n\n";

cout << "\n ENTER FIRST NUMBER  : ";
cin  >> firstNumber;

cout << "\n ENTER OPERATOR SIGN : ";
cin  >> operation;

resultSqrt = sqrt (firstNumber);

resultSin = sin (firstNumber*PI/180);

resultCos = cos (firstNumber*PI/180);

resultTan = tan (firstNumber*PI/180);

switch(operation)
{
case '+':
cout << "\n ENTER SECOND NUMBER : ";
cin  >> secondNumber;
cout << "\n Answer = " << (firstNumber + secondNumber);
break;

case '-':
cout << "\n ENTER SECOND NUMBER : ";
cin  >> secondNumber;
cout << "\n Answer = " << (firstNumber - secondNumber);
break;

case '*':
case 'x':
case 'X':
cout << "\n ENTER SECOND NUMBER : ";
cin  >> secondNumber;
cout << "\n Answer = " << (firstNumber * secondNumber);
break;

case '/':
cout << "\n ENTER SECOND NUMBER : ";
cin  >> secondNumber;
cout << "\n Answer = " << (firstNumber / secondNumber);
break;

case '!':
cout << "\n ANSWER = " << resultSqrt;
break;

case 'S':
case 's':
cout << "\n ANSWER = " << resultSin;
break;

case 'C':
case 'c':
cout << "\n ANSWER = " << resultCos;
break;

case 'T':
case 't':
cout << "\n ANSWER = " << resultTan;
break;

default:
cout << "\n WRONG MATHMATICAL OPERATOR!";
break;

}
system("PAUSE > nul");
}``````

is it java?why you post this one here???

.,'its nice program bro!!!nice one!

.,'can you make a simple java pogram like this one?...
if you did kindly post it if you mind....

It's C++, and i've added things like ^ (to the power of)

Great work but no comments, program is simple enough though.

I think its a very good program, im in my first year in my college and this program is my first assignment , im very glad that i found the program its quite nice but i hope to modify it and make it more complex so that i can get an A+ (hehe!). dont worry i wount copy and paste it, i need to understand it then build my own program using this one as reference. thanks alot man ur the best.

c program code need here..!!!

2.SUBTRACTION // if you press 2 it will ask you two numbers to be subtract
3.MULTIPLICATION// if you press 3 it will ask you two numbers to be multiply
4.DIVITION // if you press 4 it will ask you two numbers to be divide

A = SIN // if you press A it will ask you a number to convert into SIN
B = COS // if you press B it will ask you a number to convert into COS
C = TAN // if you press C it will ask you a number to convert into TAN

pls help me to solve this problem

thank u..!

Reverend Jim 3,643

You start by reading the Daniweb Posting Rules and Posting Suggestions to increase your chances of getting a timely (and more useful) response.

You might also benefit by starting a new thread instead of hijacking one that is more than nine years old.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.