//*********************************************************************** // Float_error2.cpp // // this is program experiments with floating point computations and // the limitations of the digital representations of floating point // numbers. // //*********************************************************************** // INPUTS: an initial floating point value in input from the keyboard // // OUTPUTS: the computational results are displayed on the screen // //*********************************************************************** // WARNING: none // //*********************************************************************** // IMPLEMENTATION NOTE: none // //*********************************************************************** // created by: j. aleshunas // created on: 26 may 04 // modified on: 26 may 04 // // © 2004 John Aleshunas // //*********************************************************************** #include "Float_error2.h" void main(void) { // storage for a float value float fStarting_value; // get an initial float value cout << "Enter an inintial float value: "; cin >> fStarting_value; cout << endl << endl << endl; // create the float number instance for this session Float_store fclFloat_value(fStarting_value); // storage for a character value to pause the screen display char cPause; // the bNot_finished flag controls the main menu loop bool bNot_finished = true; // the menu selection int iMenu_selection; // start a while loop toggled by the bNot_finished flag while(bNot_finished) { // infinite loop cout << endl; cout << " What do you want to do?" << endl; cout << endl; cout << " 1. Square the float value" << endl; cout << " 2. Root the float value" << endl; cout << " 3. Quit" << endl; cout << endl; cout << " Enter your selection --> "; cin >> iMenu_selection; cout << endl; // actions for each menu selection switch(iMenu_selection) { case 1: // multiply the float number fclFloat_value.Square(); cout << fclFloat_value.Display_value() << endl; // display the result cout << "Press a charter to continue "; cin >> cPause; cout << endl << endl << endl; break; case 2: // divide the float number fclFloat_value.Root(); cout << fclFloat_value.Display_value() << endl; // display the result cout << "Press a charter to continue "; cin >> cPause; cout << endl << endl << endl; break; case 3: // set the loop flag to quit looping bNot_finished = false; break; default: // display and error message for invalid menu selections cout << endl; cout << iMenu_selection << " is not a vaild menu selection"; cout << endl; cout << "Please make a valid choice"; cout << endl << endl; }// switch }// while return; // that's all folks }// main()