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 :).
Calculator, Includes Sin, Cos, Tan And Sqaure Root!
#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");
}
alpe gulay -1 Light Poster
alpe gulay -1 Light Poster
alpe gulay -1 Light Poster
Black Magic 15 Junior Poster
abdulfatah.p 0 Newbie Poster
mrwhales4real 0 Newbie Poster
hamlet_1 0 Newbie Poster
Reverend Jim 4,966 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.