Not to long ago i posted about trouble with a simple little math program. Well i didn't feel like having 3 different programs so i decided to create this.It's just a rough build, but i have a problem. Say i choose "1" on start. It works fine, and i can choose "1" again at the end, or "2" or "3". But when i get to the end of "3" or "2", if i try to select a number higher than it, the program closes. ex.Code:fo#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { double x1, x2, y1, y2, A, B, C, D, E, M, m, choice, End1, End2, End3; double b1, b2, h, a, t, o, x; cout<< "Please choose what type of equation you would like to solve for." <<"\n"; cout<< "If you want to solve the distance of two points enter 1."<<"\n"; cout<< "If you want to solve for the midpoint, between two points enter 2."<<"\n"; cout<< "If you want to find the area of a trapezoid enter 3."<<"\n"; cin>> choice; cin.ignore(); while (choice == 1) { cout<< "\n" <<"Hello. This program is used to find the distance between two points." <<"\n" "Please enter X1: "; cin>> x1 ; cout<< "\n"<< "Now X2: "; cin>> x2; cout<< "\n"<< "Y1: "; cin>> y1; cout<< "\n"<< "Now finally Y2: "; cin>> y2; cin.ignore (); A = x1 - x2; B = y1 - y2; C = A * A; D = B * B; E = C + D; cout<< "\n"<< "This is the distance: " << sqrt(E) <<"\n"; cout<< "If you want to do another equation enter 1."<< "\n" "If you want to find the midpoint enter 2."<<"\n"<<"If you want the are of a trap. enter 3"; cin>> choice; cin.get(); } while (choice == 2) { cout<<"Hello, this program is used to find mid point between two points." <<"\n" "Please enter X1:"; cin>> x1; cout<< "\n"<< "Now X2:"; cin>> x2; cout<< "\n"<< "Now Y1:"; cin>> y1; cout<< "\n"<< "Finally Y2:"; cin>> y2; cin.ignore(); A = x1 + x2; B = y1 + y2; A = A / 2; B = B / 2; cout<<"The midpoint of the two points is ["; cout<< A <<","; cout<< B; cout<< "]" << "\n" <<"If you want to do another equation enter 1."<<"\n" "If you want to find the midpoint enter 2."<<"\n"<<"If you want the are of a trap. enter 3"; cin>> choice; cin.get(); } while (choice == 3) { cout<< "This program finds the area of a trapezoid. Enter B1:"; cin>> b1; cout<< "\n"; cout<< "Now enter B2: "; cin>> b2; cout<< "\n"; cout<< "Now enter H: "; cin>> h; cout<< "\n"; cin.ignore(); a = b1 + b2; t = a * h; o = t / 2; cout<< "The area of the trapezoid is:" << o <<"\n"<< "If you want to do another equation enter 1."<<"\n" "If you want to find the midpoint enter 2."<<"\n"<<"If you want the are of a trap. enter 3"; cin>> choice; cin.get(); } }

I choose to find the area of a trapezoid. The program gives me an answer, now i want to find the distance between 2 points so i enter a 1. The program closes.

My original plan was to make it go back to the main menu each time but i like being able to jump quickly between the programs. I just don't know why it's doing this. Is it just because it doesn't look like "UP" the code to try and meet the loop or what? Again thanks for the help!