the user with a menu that looks like the text below.

Choose 1 of the following choices:

1 – Convert Miles to Kilometers

2 – Calculate the distance between two (x,y) coordinates

3 -- Quit

if they choose 1- i need to ask them if they want to randomly generate numbers to convert to kilos or use there own. same thing with 2. this is wht i have so far,it compiles ok but the stuff doesnt do what i choose except 3.

#include<iostream> #include<cmath> #include<cstdlib> #include<ctime> using namespace std; void instruct() { cout << "This program does two things."<endl; cout<<"It computes the distance between two points and converts miles to kilometers using random number generation"<<endl; cout<<"Or your own numbers, and it converts miles to kilometers the same way." <<endl; cout<<"Enter the what function you want to do and follow the in "<<endl; cout<<"program instructions that will help you succesfully complete the function"<<endl; } void menu() { cout<<"Choose one of the following choices:"<<endl; cout<<"1-Convert miles to kilometers"<<endl; cout<<"2-Calculate the distance between two coordinates"<<endl; cout<<"3-Quit"<<endl; } int main(){ srand(time(0) ); int min,max,randx1,randy1,randx2,randy2,temp; randx1=min+max+rand()%(max-min+1); randy1=min+max+rand()%(max-min+1); randx2=min+max+rand()%(max-min+1); randy2=min+max+rand()%(max-min+1); string yes; string no; int choice; int num; double KM_PER_MILE = 1.609; // for storing a constant: 1.609 km equals a mile double miles; // for storing the input data: distance in miles double kms; // for storing the result: distance in kilometers double distance; // distance of two points formula int x1, x2, y1, y2; // coordinates cout<<"Choose one of the following choices:"<<endl; cout<<"1-Convert miles to kilometers"<<endl; cout<<"2-Calculate the distance between two coordinates"<<endl; cout<<"3-Quit"<<endl; cin>>num; switch (num) { case 1: cout << "Would you like to use random number generation or enter your own numbers?"<<endl; break; case 2: cout << "Would you like to use random number generation or enter your own numbers?"<<endl; // rest of code here break; case 3: cout << "End of program"<<endl; // End of program statements cout << "Please press enter once or twice to end..."; cin.ignore().get(); // hold console window open return EXIT_SUCCESS; // successful termination break; default: cout << "Not a Valid Choice"; cin>>num; break; } if (num==1) { cout<<"Answer yes for random number generation and no to choose your own numbers"<<endl; cin>>choice; if (choice=='yes') cout<<"Enter minimum value"<<endl; cin>>min; cout<<"Enter maximum value"<<endl; cin>>max; if (min>max) min=temp; max=min; min=max; } miles=randx1; cout<<"The distance in miles is"<<miles<<endl; kms = KM_PER_MILE * miles; cout << "The distance in kilometers is:"<<kms<< endl; if (choice=='no') { cout<<"Enter miles"<<endl; cin>>miles; kms = KM_PER_MILE * miles; cout << "The distance in kilometers is:"<<kms<< endl; } //*************************************************************** if (num==2) { cout<<"Answer yes for random number generation and no to choose your own numbers"<<endl; cin>>choice; } if (choice=='yes') { cout<<"Enter minimum value"<<endl; cin>>min; cout<<"Enter maximum value"<<endl; cin>>max; } if (min>max) { min=temp; max=min; min=max; } distance = sqrt(((randx1+randx2)*(randx1+randx2))+((randy1+randy2)*(randy1+randy2))); cout<<"The distance in miles is"<<distance<<endl; if (choice=='no') { cout << "Enter x1: "; // prompt user to input first point cin >> x1; // read data from keyboard cout << "Enter x2: "; // prompt user to input second point cin >> x2; // read data from keyboard cout << "Enter y1: "; // prompt user to input third cin >> y1; // read data from keyboard cout << "Enter y2: "; // prompt user to input fourth cin >> y2; // read data from keyboard distance = sqrt(((x1-x2)*( x1-x2 ))+ ((y1-y2)*( y1-y2 ))); cout << "The distance is "<<distance<<endl; } // End of program statements cout << "Please press enter once or twice to end..."; cin.ignore().get(); // hold console window open return EXIT_SUCCESS; // successful termination }

MOD EDIT: When posting code...USE CODE TAGS!!!

This post has been edited by **JackOfAllTrades**: 20 November 2010 - 12:15 PM