Code:
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
/*
Name: Advanced Math Calculator v.2, Beta 1
Description: Advanced Mathematics calculator using advanced and standardized algorithms
Date: June 18, 2002 - June ...?
*/
void one(void)
{
int choice1;
choice1 = 1, 2, 3, 4, 5, 6, 7;
float add1, add2, sub1, sub2, mult1, mult2, div1, div2, base, pwr, sq_rt, prcnt1, prcnt2;
cout<<"Standard Calculations using basic algorithms"<<endl<<endl;
cout<<"What is the operation you wish to perform?"<<endl<<endl;
cout<<"1 - Addition"<<endl;
cout<<"2 - Subtraction"<<endl;
cout<<"3 - Multiplication"<<endl;
cout<<"4 - Division"<<endl;
cout<<"5 - Root & Power configuration"<<endl;
cout<<"6 - Square roots"<<endl;
cout<<"7 - Percentages"<<endl<<endl;
cin>>choice1;
cout<<"********************************************************"<<endl<<endl;
if (choice1 == 1)
{
cout<<"What do you wish to add?"<<endl<<endl;
cout<<":";
cin>>add1;
cout<<"+"<<endl;
cin>>add2;
cout<<"="<<endl;
cout<<add1<<" + "<<add2<<" = "<<add1 + add2<<endl<<endl;
}
else if(choice1 == 2)
{
cout<<"What do you wish to subtract?"<<endl<<endl;
cout<<": ";
cin>>sub1;
cout<<"-"<<endl;
cin>>sub2;
cout<<"="<<endl;
cout<<sub1<<" - "<<sub2<<" = "<<sub1 - sub2<<endl<<endl;
}
else if(choice1 == 3)
{
cout<<"What do you wish to multiply?"<<endl<<endl;
cout<<": ";
cin>>mult1;
cout<<"*"<<endl;
cin>>mult2;
cout<<"="<<endl;
cout<<mult1<<" * "<<mult2<<" = "<<mult1 * mult2<<endl<<endl;
}
else if(choice1 == 4)
{
cout<<"What do you wish to divide?"<<endl<<endl;
cout<<": ";
cin>>div1;
cout<<"/";
cin>>div2;
cout<<"=";
cout<<div1<<" / "<<div2<<" = "<<div1 / div2<<endl<<endl;
}
else if(choice1 == 5)
{
cout<<"What is the base (root coefficient) of this equation?"<<endl<<endl;
cin>>base;
cout<<"What is the power (exponential coefficient) of this equation?"<<endl<<endl;
cout<<"^"<<endl;
cin>>pwr;
cout<<base<<"^"<<pwr<<" = "<<pow(base, pwr)<<endl<<endl;
}
else if(choice1 == 6)
{
cout<<"What is the number you wish to find the squared-root of?"<<endl<<endl;
cin>>sq_rt;
if (sq_rt >= 1)
{
cout<<"Output for "<<sq_rt<<" is "<<sqrt(sq_rt)<<endl<<endl;
}
else
{
cout<<"Error, Bad input. Halting program..."<<endl<<endl;
}
}
else if(choice1 == 7)
{
cout<<"What is the standard (upper) coeffieicnt, or the number you"<<endl;
cout<<"wish to find a certain percentage of?"<<endl<<endl;
cin>>prcnt1;
cout<<"What is the subordinate (lower) coefficient, or the"<<endl;
cout<<"percentile of the previous number you wish to find?"<<endl<<endl;
cin>>prcnt2;
cout<<prcnt2<<" percent of "<<prcnt1<<" is "<<(prcnt2/100)*prcnt1<<endl<<endl;
}
else
{
cout<<"Bad input, halting program"<<endl<<endl;
}
}
void two(void)
{
int choice2;
float side1;
float side2;
float base;
float height;
float radius;
float pi;
pi = 3.1415926535897932384626433832795;
cout<<"Surface-area calculator"<<endl<<endl;
cout<<"What do you wish to perform?"<<endl<<endl;
cout<<"1 - Area Calculator (2-D)"<<endl;
cout<<"2 - Surface-area Calculator (3-D)"<<endl<<endl;
cin>>choice2;
cout<<"********************************************************"<<endl<<endl;
if(choice2 == 1)
{
cout<<"Area Calculator for two-dimentional objects"<<endl<<endl;
//triangle, square, rectangle, circle, paralellogram, trapezoid
}
else if(choice2 == 2)
{
cout<<"Surface-area Calculator for three-dimentional objects"<<endl<<endl;
//triangular prism, cube, sphere, rectangular prism, pyramid, cone,
}
}
void three(void)
{
int choice3;
/*Volumetrics*/
}
void four(void)
{
int choice4;
choice4 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;
float sin1, cos1, tan1;
float asin1, acos1, atan1;
float log_10, log_n;
cout<<"Advanced Trigonometrics using advanced algorithms"<<endl<<endl;
cout<<"What operation do you wish to perform?"<<endl<<endl;
cout<<"1 - Sine Calculation"<<endl;
cout<<"2 - Cosine Calculation"<<endl;
cout<<"3 - Tangent Calculation"<<endl;
cout<<"4 - Arc-Sine Calculation"<<endl;
cout<<"5 - Arc-Cosine Calculation"<<endl;
cout<<"6 - Arc-Tangent Calculation"<<endl;
cout<<"7 - SINH() Calculation"<<endl;
cout<<"8 - COSH() Calculation"<<endl;
cout<<"9 - TANH() Calculation"<<endl;
cout<<"10 - Base 10 Logarithms"<<endl;
cout<<"11 - Base e (natural) Logarithms"<<endl;
cout<<"12 - Section 2 --> Trigonometrics using visual input"<<endl<<endl;
cin>>choice4;
cout<<"********************************************************"<<endl<<endl;
if(choice4==1)
{
cout<<"What degree do you wish to find the sine of?"<<endl;
cin>>sin1;
if (sin1>180 || sin1<0)
{
cout<<"The degree must be between 0 and 180 degrees"<<endl<<endl;
}
else
{
cout<<"sin("<<sin1<<") = "<<sin(sin1)<<endl<<endl;
}
}
else if(choice4==2)
{
cout<<"What degree do you wish to find the cosine of?"<<endl;
cin>>cos1;
if (cos1>180 || cos<0)
{
cout<<"The degree must be between 0 and 180 degrees"<<endl<<endl;
}
else
{
cout<<"cos("<<cos1<<") = "<<cos(cos1)<<endl<<endl;
}
}
else if(choice4==3)
{
cout<<"What degree do you wish to find the tangent of?"<<endl;
cin>>tan1;
if (tan1>180 || tan1<0)
{
cout<<"The degree must be between 0 and 180 degrees"<<endl<<endl;
}
else
{
cout<<"tan("<<tan1<<") = "<<tan(tan1)<<endl<<endl;
}
}
else if(choice4==4)
{
cout<<"What ratio do you wish to find the arc-sine of?"<<endl;
cin>>asin1;
if (asin1>180 || asin1<0)
{
cout<<"The degree must be between 0 and 180 degrees"<<endl<<endl;
}
else
{
cout<<"asin("<<asin1<<") = "<<asin(asin1)<<endl<<endl;
}
}
else if(choice4==5)
{
cout<<"What ratio do you wish to find the arc-cosine of?"<<endl;
cin>>acos1;
if (acos1>180 || acos1<0)
{
cout<<"The degree must be between 0 and 180 degrees"<<endl<<endl;
}
else
{
cout<<"acos("<<acos1<<") = "<<acos(acos1)<<endl<<endl;
}
}
else if(choice4==6)
{
cout<<"What ratio do you wish to find the arc-tangent of?"<<endl;
cin>>atan1;
if (atan1>180 || atan1<0)
{
cout<<"The degree must be between 0 and 180 degrees"<<endl<<endl;
}
else
{
cout<<"atan("<<atan1<<") = "<<atan(atan1)<<endl<<endl;
}
}
else if(choice4 == 7)
{
//sinh
}
else if(choice4 == 8)
{
//cosh
}
else if(choice4 == 9)
{
//tanh
}
else if(choice4==10)
{
cout<<"What number do you wish to find the base-10 logarithm of?"<<endl;
cin>>log_10;
cout<<"log10("<<log_10<<") = "<<log10(log_10)<<endl<<endl;
}
else if(choice4==11)
{
cout<<"What number do you wish to find the natural logarithm of?"<<endl;
cin>>log_n;
cout<<"log("<<log_n<<") = "<<log(log_n)<<endl<<endl;
}
else if(choice4==12)
{
int trig_s2;
trig_s2 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11;
cout<<"********************************************************"<<endl;
cout<<"Trigonometrics section 2 --> Trigonometrics using visual input"<<endl<<endl;
cout<<"What operation do you wish to perform?"<<endl<<endl;
cout<<"1 - Find the sine of a triangle when given two sides"<<endl;
cout<<"2 - Find the sine of a triangle when given one side and one angle"<<endl;
cout<<"3 - Find the cosine of a triangle when given two sides"<<endl;
cout<<"4 - Find the cosine of a triangle when given one side and one angle"<<endl;
cout<<"5 - Find the tangent of a triangle when given two sides"<<endl;
cout<<"6 - Find the tangent of a triangle when given one side and one angle"<<endl;
cout<<"7 - Find the angle of a triangle when given two sides that equal sine"<<endl;
cout<<"8 - Find the angle of a triangle when given two sides that equal cosine"<<endl;
cout<<"9 - Find the angle of a triangle when given two sides that equal tangent"<<endl;
cout<<"10 - Find the hypotenuse when given two sides"<<endl;
cout<<"11 - Find the missing side when given (a^2) |or| (b^2) and c^2"<<endl;
cin>>trig_s2;
cout<<"********************************************************"<<endl<<endl;
if(trig_s2==1)
{
/* 2sidesine */
}
else if(trig_s2==2)
{
/* 1sidesine */
}
else if(trig_s2==3)
{
/* 2sidecosine */
}
else if(trig_s2==4)
{
/* 1sidecosine */
}
else if(trig_s2==5)
{
/* 2sidetangent */
}
else if(trig_s2==6)
{
/* 1sidetangent */
}
else if(trig_s2==7)
{
/* angle_sine */
}
else if(trig_s2==8)
{
/* angle_cosine */
}
else if(trig_s2==9)
{
/* angle_tangent */
}
else if(trig_s2==10)
{
/* 2sidehypotenuse */
}
else if(trig_s2==11)
{
/* missingside */
}
}
else
{
cout<<"Bad input, halting program";
}
}
void five(void)
{
/*Advanced algorithms & calculus --> LEAVE UNTIL THE END!!!*/
cout<<"********************************************************"<<endl<<endl;
}
void six(void)
{
//Unit conversion --> SI prefixes first!!!
cout<<"********************************************************"<<endl<<endl;
}
int main(int argc, char *argv[])
{
int choice_main;
choice_main = 1,2,3,4,5,6,7;
cout<<"********************************************************"<<endl;
cout<<"Welcome to the Advanced Mathematics Calculator"<<endl;
cout<<"Programmed by Dead Cell"<<endl;
cout<<"[email protected]"<<endl;
cout<<"********************************************************"<<endl<<endl;
cout<<"Which function of the calculator do you wish to utilize?"<<endl<<endl;
cout<<"1 - Standard Calculations using basic algorithms"<<endl;
cout<<"2 - Advanced Surface-area calculating using advanced algorithms"<<endl;
cout<<"3 - Advanced Volume calculations based on advanced algorithms"<<endl;
cout<<"4 - Advanced Trigonometrics using advanced algorithms"<<endl;
cout<<"5 - Advanced use of scientific algorithms and mathematical observations"<<endl;
cout<<"6 - Standard unit conversion"<<endl;
cout<<"7 - Exit"<<endl<<endl;
cout<<":";
cin>>choice_main;
cout<<"********************************************************"<<endl<<endl;
switch(choice_main)
{
case 1 : one();
break;
case 2 : two();
break;
case 3 : three();
break;
case 4 : four();
break;
case 5 : five();
break;
case 6 : six();
break;
case 7 :
return 0;
default:
cout<<"Error, bad input, halting program"<<endl<<endl;
}
system("PAUSE");
return 0;
}
PS: Sorry 'bout that...