# looking for volunteers to help me out on MathOps

Page 1 of 1

## 5 Replies - 2001 Views - Last Post: 19 January 2013 - 01:35 PM

### #1 AhmerjavedC++

• D.I.C Regular

Reputation: 0
• Posts: 253
• Joined: 02-October 09

# looking for volunteers to help me out on MathOps

Posted 17 January 2013 - 10:31 PM

Hi All,

I am looking for volunteers to help me make this program better and more efficient as this is a project that i am doing in order to make myself better at math and C++. Anyone can jump in. I have decided to make it a opensource program.

```/*
Name: Mathops
Author: Ahmer Javed
Date: 10/01/13 23:21
Description: Does multiple operations in Mathematics
*/

#include<iostream>
#include<cmath>
#include<conio.h>
using namespace std;
const double PI = 3.1415926;
void description();
void Derivative_calculations();
void formulas();
//void Equation_calculations();
int main()
{
int choice;
double num,exp;
char Ans,Ans2,Ans3,Repeat_program;

description();
do
{
cout <<"What would you like to calculate?"; // options to the user
cout << endl;
cout << "1.Derivative Calculations";
cout << endl;
cout << "2.Formulas";
cout << endl;
// cout << "3.Equation Calculations";
// cout << endl;
cout << "Enter your choice: ";
cin  >> choice;
cout << endl;
// While option 1 is chosen
while ((choice != 2)||(choice != 1))
{
choice = 0;
cout << "ERROR: Choice is invalid";
cout << endl;
cin >> choice;
cout << endl;
choice = 0;
}//  while(choice == 3)
while (choice == 1)
{
Derivative_calculations();
cout << endl << endl;
cout <<"would you like to continue calculating derivatives?: ";
cin  >> Ans;
if ((Ans == 'Y')||(Ans == 'y'))
{
choice = 1;
}// closes if ((Ans == 'Y')||(Ans == 'y'))
else if ((Ans == 'N')||(Ans == 'n'))
{
choice = 0;
} // closes  else if ((Ans == 'N')||(Ans == 'n'))
}// closes  while (choice == 1)
while (choice == 2)
{
formulas();
cout << endl << endl;
cout <<"would you like to continue calculating Formulas: ";
cin  >> Ans2;
if ((Ans2 == 'Y')||(Ans2 == 'y'))
{
choice = 2;
}// closes if ((Ans2 == 'Y')||(Ans2 == 'y'))
else if ((Ans2 == 'N')||(Ans2 == 'n'))
{
choice = 0;
} // closes  else if ((Ans2 == 'N')||(Ans2 == 'n'))

} // closes while (choice == 2)

cout <<"Would you like to continue running this Program?:"; // asks user if they want to repeat the program
cin  >> Repeat_program;
cout << endl;

}while((Repeat_program == 'y')||(Repeat_program == 'Y'));
cout << endl << endl;
cout << "<Program End>";
cout << endl << endl;
system("Pause");
}// closes int main()
void description()
{
cout <<"welcome to the program math operations";
cout << endl;
cout << "this program is useful for many areas of mathematics";
cout << endl;
}// close void description()
void Derivative_calculations() // code from derivative program
{
int choice_1;
double num,exp;
char variable;

cout << endl << endl;
cout << "what kind of derivative would you like to find?";
cout << endl;
cout << "1.single derivative";
cout << endl;
cout << "2.Product Rule";
cout << endl;
cout << "Enter your choice: ";
cin  >> choice_1;
if(choice_1 == 1)
{
double number, number1, exponent, exponent1;
char variable, carrot;
cout << "example: f(x) = 2x^3\n";
cout << "example: f(x) = 2  enter as 2 - ^ 1";
cout << endl;
cout << "example: f(x) = x^4 enter as 1x^4";
cout << endl;
cout << "Enter the function as given in example:" << endl;
cin >> number >> variable >> carrot >> exponent;

if((variable == '-')&&(exponent == 1))
{
cout << endl;
cout << "the derivative of: " <<number << " is " << "0";
cout << endl << endl;
}// closes if((variable == '-')&&(exponent == 1))
if((variable == 'X')||(variable == 'x'))
{
number1 = number * exponent;
exponent1 = exponent - 1;
if(exponent1 == 1)
{
cout << "the derivative of function: "<< number << variable << "^" << exponent;
cout << endl;
cout << endl << "is " << number1 << variable;
cout << endl << endl;
}// closes if((variable == 'X')||(variable == 'x'))

if(exponent1 == 0)
{
cout << "the derivative of function: "<< number << variable << "^" << exponent;
cout << endl;
cout << endl << "is " << number1;
}// closes  if(exponent1 == 0)
if((exponent1 != 0)&&(exponent1 != 1))
{
cout << "the derivative of function: "<< number << variable << "^" << exponent;
cout << endl;
cout << endl << "is " << number1 << variable << "^" << exponent1;
} // closes if statement if((exponent1 != 0)&&(exponent1 != 1))
}// closes if statement ((variable == 'X')||(variable == 'x'))
}// closes  if(choice_1 == 1)
if(choice_1 == 2)
{
double number, exponent;
double number_1, exponent_1;
double number_2, exponent_2;
double number_sol, exponent_sol;
double number_sol_1, exponent_sol_1;
char Parenthesis;
char variable, carrot;
char variable_1;
char variable_2;

cout << "example: (2x^3)(3-^4)";
cout << endl;
cout << "example:  2 enter as (2-^1)";
cout << endl;
cout << "Enter functions just like example:" << endl;
cin >> Parenthesis >> number >> variable >> carrot >> exponent >> Parenthesis;
cin >> Parenthesis >> number_1 >> variable_1>> carrot >> exponent_1>>Parenthesis;
if((variable == '-')||(variable_1 == '-'))
{
if(variable == '-')
{
number = pow(number,exponent);
number_sol = number * number_1;
number_sol = number_sol * exponent_1;
exponent_sol = exponent_1 - 1;
cout <<"The derviative is: "<<number_sol << variable_1 << "^" << exponent_sol;
}// closes  if(variable == '-')
if(variable_1 == '-')
{
number_1 = pow(number_1, exponent_1);
number_sol = number * number_1;
number_sol = number_sol * exponent;
exponent_sol = exponent - 1;
cout <<"The first derviative is: "<<number_sol << variable << "^" << exponent_sol;
}// closes   if(variable_1 == '-')
}// closes  if((variable == '-')||(variable_1 == '-'))
if((variable_1 == 'x')&&(variable == 'x'))
{
number_sol = number * number_1;
exponent_sol = exponent + exponent_1;
number_sol = exponent_sol * number_sol;
exponent_sol = exponent_sol - 1;
cout <<"The first derviative is: "<<number_sol << variable << "^" << exponent_sol;
}// closes  if((variable_1 == 'x')&&(variable == 'x'))
cout << endl;
number_sol_1 = number_sol * exponent_sol;
exponent_sol_1 = exponent_sol - 1;

if(exponent_sol_1 == 1)
{
cout <<"The second derivative is: "<<number_sol_1 << "x";
}// closes if(exponent_sol_1 == 1)
if(exponent_sol_1 > 1)
{
cout <<"The second derivative is: "<<number_sol_1 << "x" << "^"<< exponent_sol_1;
}// closes if(exponent_sol_1 > 1)
if(exponent_sol_1 < 1)
{
cout <<"The second derivative is: "<<number_sol_1;
} // closes  if(exponent_sol_1 < 1)
} // closes if statement ((variable == 'X')||(variable == 'x'))
}// closes function void Derivative_calculations()
void formulas()
{
int choice_3;
cout <<"what formula would you like to run?"; //asks user
cout << endl;
cout <<"1. Temprature conversion (from F to C and vice versa)"; // Temp program
cout << endl;
cout <<"2. Square Area Formula and Perimeter"; // from geo program
cout << endl;
cout <<"3. Circle formulas (Area and all that)"; // From geo Program
cout << endl;
cout <<"4. Rectangle formulas(Area and all that)" // new
cout << endl;
cin >> choice_3;
cout << endl;
if (choice_3 == 1)
{
int ch;
float ctemp,ftemp;
cout <<"1.celsius to Fahrenheit" << endl;
cout <<"2.Fahrenheit to Celsius" << endl;
cout << "choose between 1&2: " << endl;
cin >> ch;
if (ch == 1)
{
cout << "Enter the temprature in Celsius :" << endl;
cin >> ctemp;
ftemp = (1.8*ctemp)+32;
cout << "temprature in Farenheit =" << ftemp << "F" <<endl;
}// closes if (choice == 1)
else
{
cout <<"Enter the temprature in Fahrenheit:" << endl;
cin >> ftemp;
ctemp = (ftemp - 32)/1.8;
cout <<"temprature in celsius = " << ctemp << "C" << endl;
}// closes else statement
}// closes  if (choice_3 == 1)
if (choice_3 == 2)
{
double square_area, square_perimeter;
double square_side;

cout << "enter a side of the square:";
cin >> square_side;
cout << endl;
square_area = square_side * square_side;
square_perimeter = square_side + square_side + square_side + square_side;

cout <<"Area of Square: " << square_area;
cout << endl;
cout <<"Perimeter of Square:"<< square_perimeter;
cout << endl;
}// if (choice_3 == 2)
if(choice_3 == 3)
{
char Theta_given;
double angle_in_degrees;
double circumference, diameter, area, Length_of_Arc, Area_of_Sector;
cout << "Enter the Radius of the circle: ";
cout << endl << endl;
cout << "Angle given? (y or n): ";
cin >> Theta_given;
if ((Theta_given == 'y')||(Theta_given == 'Y'))
{
cout <<"Is that Angle given in Radians?: ";
cout << endl << endl;
{
cout << "Enter the Angle: ";
cout << endl << endl;
{
cout << "Enter the Angle: ";
cin >> angle_in_degrees;
cout << endl << endl;
}// closes   else if((Theta_given == 'n')||(Theta_given == 'N))
}// closes  ((Theta_given == 'y)||(Theta_given == 'Y'))
circumference = PI * diameter;

cout << "diameter: " << diameter;
cout << endl;
cout << "circumference: " << circumference;
cout << endl;
cout << "Area of Circle: " <<area;
cout << endl;
if((Theta_given == 'y')||(Theta_given == 'Y'))
{
cout << "Sector Area: " <<Area_of_Sector;
cout << endl;
cout << "Length of Arc: "<< Length_of_Arc;
cout << endl;
}
}// closes  if(choice_3 == 3)
if (choice_3 == 4)
{
double Rectangle_length, Rectangle_Width;
double Rectangle_area, Rectangle_perimeter;

cout << "Enter the width of the rectangle: ";
cin >> Rectangle_Width;
cout << endl << endl;
cout << "Enter the length of the rectangle: ";
cin  >> Rectangle_length;
cout << endl << endl;

Rectangle_perimeter = 2 * (Rectangle_Width + Rectangle_length);
Rectangle_area = Rectangle_length * Rectangle_Width;

cout << "Perimeter of Rectangle: " << Rectangle_perimeter;
cout << "Area of Rectangle: " << Rectangle_area;
cout << endl << endl;
} // Closes if (choice_3 == 4)
if(choice_3 == 5)
{
double Triangle_area, Triangle_perimeter;
double Triangle_Base, Triangle_height;
char tri_ans;

cout <<"Would you like to find area of Triangle?: ";
cout << endl;
if(tri_ans == 'y')
{
cout << "Enter the base of the triangle: ";
cin >> Triangle_Base;
cout << endl;
cout << "Enter the the height of the triangle: "
cin >> Triangle_height;
cout << endl;

}// closes void formulas()

```

Deadline for version 1.0 is January 25th. I have a beta build up on my website.

http://ahmerjaved.we.../apps/calendar/

Is This A Good Question/Topic? 0

## Replies To: looking for volunteers to help me out on MathOps

### #2 modi123_1

• Suitor #2

Reputation: 8377
• Posts: 31,135
• Joined: 12-June 08

## Re: looking for volunteers to help me out on MathOps

Posted 17 January 2013 - 10:32 PM

Moving to 'post a job'.

### #3 macosxnerd101

• Self-Trained Economist

Reputation: 10185
• Posts: 37,603
• Joined: 27-December 08

## Re: looking for volunteers to help me out on MathOps

Posted 17 January 2013 - 10:37 PM

You should look into Numerical Methods. There are numerical methods for integration like Simpson's Rule and the Trapezoidal Rule. You can also use Euler's Method and Runge-Kutta as a couple examples for solving differential equations.

Also, just a suggestion, but you should really work on design. Your code really looks like the byproduct of an intro class. It doesn't scale well as you expand.

### #4 AhmerjavedC++

• D.I.C Regular

Reputation: 0
• Posts: 253
• Joined: 02-October 09

## Re: looking for volunteers to help me out on MathOps

Posted 19 January 2013 - 09:15 AM

Well ofcourse i took Intro To C++ in High School and thats the level of C++ programming i Know.

### #5 macosxnerd101

• Self-Trained Economist

Reputation: 10185
• Posts: 37,603
• Joined: 27-December 08

## Re: looking for volunteers to help me out on MathOps

Posted 19 January 2013 - 09:45 AM

Time to work on improving your skillset then in C++.

### #6 AhmerjavedC++

• D.I.C Regular

Reputation: 0
• Posts: 253
• Joined: 02-October 09

## Re: looking for volunteers to help me out on MathOps

Posted 19 January 2013 - 01:35 PM

Yeah I am learning Java at the Moment at the University this is just for my free time. Oh yeah Any Suggestions and stuff i will keep in mind for version 1.1 which i will work on in May. Just the deadline is too tight to fit all your suggestions in and i will need to learn those stuff. The stuff in MathOps is stuff that i have memorized