Code:#include <math.h> #include <iostream> using namespace std; int main() { int x1,x2,y1,y2,answer,answerx,answery; double distance; char choice; cout << "Menu:\nm = Midpoint\nd = Distance\ns=Slope\np=Slope Point\n"; cin >> choice; while(choice != 'x') { if(choice == 'm') { cout << "Enter the X1 coordinate: "; cin >> x1; cout << "Enter the Y1 coordinate: "; cin >> y1; cout << "Enter the X2 coordinate: "; cin >> x2; cout << "Enter the Y2 coordinate: "; cin >> y2; answerx = (((x1) + (x2))/2); answery = (((y1) + (y2))/2); printf("The Midpoint is : (%i,%i)\n",answerx,answery); } if(choice == 'd') { cout << "Enter the X1 coordinate: "; cin >> x1; cout << "Enter the Y1 coordinate: "; cin >> y1; cout << "Enter the X2 coordinate: "; cin >> x2; cout << "Enter the Y2 coordinate: "; cin >> y2; distance = sqrt(pow(x2-x1,2) + pow(y2-y1,2)); printf("The Distance is: %i\n",distance); } if(choice == 's') { cout << "Enter The X1 Coordinate: "; cin >> x1; cout << "Enter The Y1 Coordinate: "; cin >> y1; cout << "Enter The X2 Coordinate: "; cin >> x2; cout << "Enter The Y2 Coordinate: "; cin >> y2; printf("M = %i - %i / %i - %i\n",y2,y1,x2,x1); } if(choice == 'p') { cout << "Enter The Y Coordinate: "; cin >> y1; cout << "Enter The X Coordinate: "; cin >> x1; printf("y - %i = m(x - %i)\n",y1,x1); } system("Pause"); break; } }
Results 1 to 3 of 3
- 01 Jul. 2010 04:04pm #1
[C++]Some math calculator I used in Highschool.
- 01 Jul. 2010 04:12pm #2
Just in case someone tries to compile this in a non-Windows environment: system("Pause") only works on Windows.
- 11 Jul. 2010 04:14am #3
Oh. I forgot about that. Thanks for the tip off.