// A sample program that computes volumes of four-sided pyramids // with square bases. #include using namespace std; #include void Hello( void ); void DisplayMenu( void ); void ComputeOnce( void ); void ComputeDifference( void ); void MakeTable( void ); void Goodbye( void ); void main( void ) { int choice; Hello(); do { DisplayMenu(); cout << "Enter your selection: "; cin >> choice; if ( choice == 1 ) ComputeOnce(); else if ( choice == 2 ) ComputeDifference(); else if ( choice == 3 ) MakeTable(); else if ( choice != 4 ) { cout << endl << "Please enter a number from 1 to 4"; cout << endl << endl; } } while ( choice != 4 ); Goodbye(); } void Hello( void ) { cout << endl; cout << " Pyramid Volume Calculations" << endl; cout << endl; cout << " Compute the volume of square-based pyramids" << endl; cout << endl << endl; } void Goodbye( void ) { cout << endl; cout << "Have a nice day." << endl; cout << endl << endl; } void DisplayMenu( void ) { cout << endl; cout << "Choose from the following options..." << endl; cout << "(1) Compute the volume of one pyramid" << endl; cout << "(2) Compute the difference between" << endl; cout << " the volume of two pyramids" << endl; cout << "(3) Make a table of pyramid volumes" << endl; cout << "(4) Exit the program" << endl; } void ComputeOnce( void ) { cout << "ComputeOnce" << endl; } void ComputeDifference( void ) { cout << "ComputeDifference" << endl; } void MakeTable( void ) { cout << "MakeTable" << endl; }