CynicalSquid
Swag Master General
It's an evolutionary adaptation that was required to help them cope with teenage boys.
Good point.
It's an evolutionary adaptation that was required to help them cope with teenage boys.
136 lines of (mostly) perfect code.
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
double add (double x, double y)
{
cout<<"Enter first number:\n";
cin >> x;
cout <<"Enter the second number:\n";
cin>> y;
cin.ignore();
double result = x + y;
cout<<"Result is"<<" "<<result<<endl;
cin.get();
return 0;
}
double subtract (double x, double y)
{ cout<<"Enter first number:\n";
cin >> x;
cout <<"Enter the second number:\n";
cin>> y;
cin.ignore();
double result = x - y;
cout<<"Result is"<<" "<<result<<endl;
cin.get();
return 0;
}
double multiply (double x, double y)
{ cout<<"Enter first number:\n";
cin >> x;
cout <<"Enter the second number:\n";
cin>> y;
cin.ignore();
double result = x*y;
cout<<"Result is"<<" "<<result<<endl;
cin.get();
return 0;
}
double divide (double x, double y)
{ cout<<"Enter first number:\n";
cin >> x;
cout <<"Enter the second number:\n";
cin>> y;
cin.ignore();
double result = x / y;
cout<<"Result is"<<" "<<result<<endl;
cin.get();
return 0;
}
double log (double x, double y)
{ cout<<"Enter the number:\n";
cin >> x;
cout <<"Enter the base:\n";
cin>> y;
cin.ignore();
double result = (log10 (x))/(log10 (y));
cout<<"Result is"<<" "<<result<<endl;
cin.get();
return 0;
}
double exponent (double x, double y)
{cout<<"Enter the Base:\n";
cin >> x;
cout <<"Enter the Exponent:\n";
cin>> y;
cin.ignore();
double result = pow(x,y);
cout<<"Result is"<<" "<<result<<endl;
cin.get();
return 0;
}
double input(double option,double x,double y)
{
while(1)
{
cout<<endl;
cout<<"-----------------------------------------------------\n"<<endl;
cout<<"Please select the option you want to perform"<<endl;
cout<<"1. Addition"<<endl<<"2. Subtraction"<<endl<<"3. Multiplication\n"<<endl
<<"4. Division\n"<<endl<<"5. Logarithm\n"<<endl<<"6. Exponent\n"<<endl<<"7. Exit Calculator\n";
cout<<"\nPlease enter your option:";
cin >>option;
switch(option){
case 1:
cout<<"You have selected Addition\n";
add(x,y);
break;
case 2:
cout<<"You have selected Subtraction\n";
subtract(x,y);
break;
case 3:
cout<<"You have selected Multiplication\n";
multiply(x,y);
break;
case 4:
cout<<"You have selected Division\n";
divide(x,y);
break;
case 5:
cout<<"You have selected Logarithms\n";
divide(x,y);
break;
case 6:
cout<<"You have selected Exponential Functions\n";
divide(x,y);
break;
case 7:
cout<<"Exiting...";
break;
default:
cout<<"Please select a valid option";
}
if (option == 7)
{
break;
}
}
}
int main()
{
cout<<"Caculator";
int option,a,b;
input(option,a,b);
getch();
return 0;
}
Get over it you pathetic fool. Stop stressing, it won't fix anything.