Code:
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <math.h>
#define stars() cout<<"**********************************************************"<<endl;
void one(void)
{
using namespace std;
int choice_1;
float add1, add2, sub1, sub2, mult1, mult2, div1, div2, base, pwr, sq_rt, prcnt1, prcnt2;
cout<<"Section one : Basic operations"<<endl<<endl;
cout<<"Please select an operation to perform from the list below:"<<endl<<endl;
cout<<"1 - Addition"<<endl<<"2 - Subtraction"<<endl<<"3 - Multiplication"<<endl<<"4 - Division"<<endl<<"5 - Root Configuration"<<endl<<"6 - Square roots"<<endl<<"7 - Percentages"<<endl<<endl;
cin>>choice_1;
stars()
if (choice_1 == 1)
{
cout<<"What do you wish to add?"<<endl<<endl;
cin>>add1;
cout<<"+"<<endl;
cin>>add2;
cout<<add1<<" + "<<add2<<" = "<<add1 + add2<<endl<<endl;
}
else if(choice_1 == 2)
{
cout<<"What do you wish to subtract?"<<endl<<endl;
cin>>sub1;
cout<<"-"<<endl;
cin>>sub2;
cout<<sub1<<" - "<<sub2<<" = "<<sub1 - sub2<<endl<<endl;
}
else if(choice_1 == 3)
{
cout<<"What do you wish to multiply?"<<endl<<endl;
cin>>mult1;
cout<<"*"<<endl;
cin>>mult2;
cout<<mult1<<" * "<<mult2<<" = "<<mult1 * mult2<<endl<<endl;
}
else if(choice_1 == 4)
{
cout<<"What do you wish to divide?"<<endl<<endl;
cin>>div1;
cout<<"/";
cin>>div2;
cout<<div1<<" / "<<div2<<" = "<<div1 / div2<<endl<<endl;
}
else if(choice_1 == 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(choice_1 == 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(choice_1 == 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;
}
stars()
}
void two(void)
{
using namespace std;
int choice_2;
float side1;
float side2;
float base;
float height;
float radius;
float pi;
pi = 3.1415926535897932384626433832795;
cout<<"Section two : Area configiration"<<endl<<endl;
cout<<"What operation do you wish to perform from the list below?"<<endl<<endl;
cout<<"1 - Area Calculator (2-D)"<<endl;
cout<<"2 - Surface-area Calculator (3-D)"<<endl<<endl;
cin>>choice_2;
stars()
if(choice_2 == 1)
{
cout<<"Area Calculator for two-dimentional objects"<<endl<<endl;
int choice_2a;
cout<<"What operation do you wish to perform from the list below?"<<endl<<endl;
cout<<"1 - Square/Rectangle"<<endl<<"2 - Triangle"<<endl<<"3 - Circle"<<endl<<"4 - Parallellogram"<<endl<<"5 - Trapezoid"<<endl<<endl;
cin>>choice_2a;
if(choice_2a == 1)
{
cout<<"Square or rectangle area calculation - here's the formula:"<<endl<<"area (a) = base (b) * height (h)"<<endl;
cout<<"Okay, what's the base of the square or rectangle?"<<endl<<endl;
cin>>base;
cout<<"Alright, I'll need the height of the square or rectangle. What is the height?"<<endl<<endl;
cin>>height;
cout<<"area = "<<base<<" * "<<height<<" = "<<base * height<<endl<<endl;
}
else if(choice_2a == 2)
{
cout<<"Triangle area calculation - here's the formula:"<<endl<<"area (a) = base (b) * height (h) / 2"<<endl;
cout<<"Okay, what's the base of the triangle?"<<endl<<endl;
cin>>base;
cout<<"Alright, I'll need the height of the triangle. What's the height?"<<endl<<endl;
cin>>height;
cout<<"area = "<<base<<" * "<<height<<" / 2 = "<<(base*height)/2<<endl<<endl;
}
else if(choice_2a == 3)
{
cout<<"Circle area calculation - here's the formula:"<<endl<<"area (a) = (pi (3.14) * r)^2"<<endl;
cout<<"Okay, what's the radius of the circle?"<<endl<<endl;
cin>>radius;
cout<<"area = (pi * r)^2 = ("<<pi<<" * "<<radius<<")^2 = "<<pow((pi * radius), 2)<<endl<<endl;
}
else if(choice_2a == 4)
{
cout<<"Parallelogram area calculation - here's the formula:"<<endl<<"area (a) = base (b) * height (h)"<<endl;
cout<<"Okay, what's the base of the paralellogram?"<<endl<<endl;
cin>>base;
cout<<"Alright, what's the height of the parallelogram?"<<endl<<endl;
cin>>height;
cout<<"area = "<<base<<" * "<<height<<" = "<<base * height<<endl<<endl;
}
else if(choice_2a == 5)
{
cout<<"Trapezoid area calculation - here's the formula:"<<endl<<"area (a) = .5 * (height (h) * (base1 (b1) + base2 (b2))"<<endl;
cout<<"Okay, what's the first base (b1) of the paralellogram?"<<endl<<endl;
cin>>side1;
cout<<"Alright, what's the second base (b2) of the parallelogram?"<<endl<<endl;
cin>>side2;
cout<<"Okay, now, I'll need the height of the parallelogram. What's the height?"<<endl<<endl;
cin>>height;
cout<<"area = .5 * ("<<height<<" * ("<<side1<<" * "<<side2<<") = "<<.5 * (height * (side1 + side2))<<endl<<endl;
}
else
{
cout<<"Bad input, halting program"<<endl<<endl;
}
}
else if(choice_2 == 2)
{
cout<<"Surface-area Calculator for three-dimentional objects"<<endl<<endl;
cout<<"What operation do you wish to perform from the list below?"<<endl<<endl;
cout<<"1 - "<<endl<<"2 - "<<endl<<"3 - "<<endl<<"4 - "<<endl<<"5 - "<<endl<<"6 - "<<endl<<endl;
//triangular prism, cube, sphere, rectangular prism, pyramid, cone,
}
else
{
cout<<"Bad input, halting program"<<endl<<endl;
}
stars()
}
void three(void)
{
using namespace std;
int choice_3;
cout<<"Section three : Volumetrics"<<endl<<endl;
stars()
}
void four(void)
{
using namespace std;
int choice_4;
cout<<"Section four : Trigonometry"<<endl<<endl;
stars()
}
void five(void)
{
using namespace std;
int choice_5;
cout<<"Section five : Advanced algorithms and Calculus"<<endl<<endl;
stars()
}
void six(void)
{
using namespace std;
int choice_6;
cout<<"Section six : Unit conversion"<<endl<<endl;
stars()
}
int main()
{
int choice_main;
choice_main = 1,2,3,4,5,6;
cout<<"Advanced Mathematic calculator v.3.0.1 BETA"<<endl;
cout<<"Programmed by Dead Cell"<<endl;
stars()
cout<<"Please select a function from the list below:"<<endl<<endl;
cout<<"1 - Basic mathematical operations"<<endl<<"2 - Area configuration"<<endl<<"3 - Volumetrics"<<endl<<"4 - Trigonometrics"<<endl<<"5 - Advanced algorithms and calculus"<<endl<<"6 - Unit conversion"<<endl<<"7 - Exit Program"<<endl<<endl;
cin>>choice_main;
stars()
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 :
cout<<"Quitting program..."<<endl<<endl;
break;
default: cout<<"Error, bad input, halting program..."<<endl<<endl;
}
system("PAUSE");
return 0;
}
Shouts out to you, man, thanks a million!