Code:
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <cmath>
using namespace std;
double a, b, s, i;
double A, l, w, h;
long H, length, width, height;
double side1, side2, side3;
double C, base, high;
double x, y, r;
// "Define the Functions"
double add (double a, double b) // Add Function
{
return a + b;
}
double subtract (double a, double b) // Subtract Function
{
return a - b;
}
double multiply (double a, double b) // Multiply Function
{
return a * b;
}
double divide (double x, double y) // Divide Function
{
return x / y;
}
//double mod (double x, double y)
//{
//return x % y;
//}
double exp (double a, double b, double s, double i)
{
s = 1;
for (i=1; i <=b; i++) // Exponential Function
s = s * a;
return s;
}
double area (double base, double high)
{
double A = 0;
A = base * high; // Area of a Square Function
return (A);
}
double cubeVol (double l, double w, double h)
{
double C = 0;
C = l * w * h; // Volume of a Cube Function
return (C);
}
//long cubeSurf (long length, long width, long height)
//{
//long surf;
//long side1 = length * height;
//long side2 = length * width;
//long side3 = height * width;
//surf = (2 * side1) + (2 * side2) + (2 * side3); // surface area
//return surf;
//}
double sqroot (double x)
{
return sqrt (x); // Square Root Function
}
// "Define the Screens"
double addscreen () // Addition Screen
{
double sum;
cout << "\n";
cout << " Enter the 1st Number to Add : "; cin >> a;
cout << " Enter the 2nd Number to add : "; cin >> b;
sum = add (a, b);
cout << "\n";
cout << " Done ...The Sum is : " << sum;
cout <<"\n";
//system ("pause");
cin.get ();
return 0;
}
double subscreen () // Subtraction Screen
{
double ans;
cout <<"\n";
cout << " Enter the Number to be Subtracted from : "; cin >> a;
cout << " Enter the Amount to Subtract : "; cin>> b;
ans = subtract (a, b);
cout << "\n";
cout << " Done ...The Answer is : " << ans;
cout << "\n";
//system ("pause");
cin.get ();
return 0;
}
double mulscreen () // Multiplication Screen
{
double prod;
cout << "\n";
cout << " Enter the Multiplicand :"; cin >> a;
cout << " Enter the Multiplier :"; cin >> b;
prod = multiply (a, b);
cout << "\n";
cout << " Done ...The Product is : " << prod;
cout << "\n";
//system ("pause");
cin.get ();
return 0;
}
double divscreen () // Division Screen
{
double q = 0;
//double r = 0;
cout << "\n";
cout << " Enter the Dividend "; cin >> x;
cout << " Enter the Divisor "; cin >> y;
q = divide (x, y);
//r = mod (x, y);
cout << "\n";
cout << " Done...The Quotent is : " << q;
//cout << " And the Remainder is :" <<r;
cout << "\n";
//system ("pause");
cin.get ();
return 0;
}
double expscreen () // Exponential Screen
{
double ans = 0 ;
cout << "\n";
cout << " Enter Number to be Raised : "; cin >> a;
cout << " Enter the power to Raise to : "; cin >> b;
ans = exp (a,b,s,i);
cout << "\n";
cout << " Done :" << a <<" Raised to the " << b
<<" Power is :" << ans;
cout << "\n";
//system ("pause");
cin.get ();
return 0;
}
double areascreen () // Area of a Square Screen
{
double A = 0;
cout << "\n";
cout << " Enter the Base : "; cin >> base;
cout << " Enter the Height : "; cin >> high;
A = area (base, high);
cout << "\n";
cout << " Done :" << "The Area of the Square is : " << A << " Square -> ft,inches,cent,etc.";
cout << "\n";
//system ("pause");
cin.get ();
return 0;
}
double cubeVolscreen () // Volume of a cube screen
{
double C = 0;
cout << "\n";
cout << " Enter the Length : "; cin >> l;
cout << " Enter the Height : "; cin >> h;
cout << " Enter the Width : "; cin >> w;
cout << " _ _ _ \n ";
cout << " /| /| \n ";
cout << " /_|_ / | \n ";
cout << " | |_ |_| \n ";
cout << " | / | / \n ";
cout << " |/_ _ |/ \n ";
C = cubeVol (l, w, h);
cout << "\n";
cout << " Done :" << "The Volume of the Cube the is : " << C << " Cubic -> ft,inches,cent,etc";
cout << "\n";
//system ("pause");
cin.get ();
return 0;
}
//long cubeSurfscreen ()
//{
//cout << "\n";
//cout << " Enter the Length : "; cin >> length;
//cout << " Enter the Height : "; cin >> height;
//cout << " Enter the Width : "; cin >> width;
//long H = 0;
//H = cubeSurf (length, width, height);
//cout << " Done : " << " The Surface Area of the Cube is : " << H << " Square -> ft, inches, cent, etc";
//cout << "\n";
//cin.get ();
//return 0;
//}
double rootscreen () // Square Root Screen
{
cout << " Enter Number to find Square Root of : ";
cin >> x;
r = sqroot (x);
cout << " The Square Root of : " << x << " is " << r;
cout << "\n";
cin.get ();
return 0;
}
// "Main Function"
int main ()
{
char choice;
cout << " Choose your Math Function \n";
cout << "\n";
cout << " 1 : Addition \n";
cout << " 2 : Subtraction \n";
cout << " 3 : Multiplication \n";
cout << " 4 : Division \n";
cout << " 5 : Area of a Square \n";
cout << " 6 : Volume of a Cube \n";
cout << " 7 : ** Surface Area of a Cube ** " << "\n";
cout << " Under Construction \n";
cout << " 8 : Exponents \n";
cout << " 9 : Square Root \n";
cout << "\n";
cout << " Enter your choice :";
cin >> choice;
switch (choice)
{
case '1':
addscreen ();
break;
case '2':
subscreen ();
break;
case '3':
mulscreen ();
break;
case '4':
divscreen ();
break;
case '5':
areascreen ();
break;
case '6':
cubeVolscreen ();
break;
// case '7':
// cubeSurf (); // Under Construction
// break;
case '8':
expscreen ();
break;
case '9':
rootscreen ();
break;
default:
cout << " Your selection is not one of the above : Try again \n ";
cout << "\n";
system ("pause");
system ("cls");
return main ();
}
cout << "\n";
cout << "Do you wish to (C)ontinue or (E)xit\n";
char restart; cin >> restart;
switch (restart)
{
case 'c':
system("CLS");
return main();
break;
case 'C':
system ("cls");
return main ();
break;
case 'e':
return 0;
break;
case 'E':
return 0;
break;
}
return 0;
}
As you can see I was trying to add another function to the collection...........I'm adding them one at a time, but the function for the surface area of a cube is causing problems......maybe in the data type...I've used both long & double, but still get an error about too few arguments..........