I've been working on this program and most things are working... However I was wondering if there is an easier way to write my last funtion without using an array... For the sorting. I need them to be sorted least to greatest I think I have it backwards at the moment. Also, the teacher recommended using swap how would I do this? This is the only function holding me up. Also is do my case five and default case statements look ok. Case five should exit and defualt should ask the user to re enter values.

Code

Code:// *************************************** //Doug Miller //Lab 3, Part 3 //Working with numbers; to compute average! //**************************************** #include <iostream> #include <iomanip> using namespace std; float Do_Sum (float, float, float); float Do_Product (float, float, float); float Do_Average (float, float, float); void Do_Sort (float&, float&, float&); void Swap(int& x, int& y); int main() { int option = 0; float v_1 = 0; float v_2 = 0; float v_3 =0; while (option != 5) { cout << "Options" << endl; cout << "-------" << endl; cout << "\n\n"; cout << "1.) Sum" << endl; cout << "2.) Product" << endl; cout << "3.) Average" << endl; cout << "4.) Sort" << endl; cout << "5.) Exit" <<endl; cout << "\n\n"; cout << "Please enter your choice: " << endl; cin >> option; switch (option) { case 1: { cout << "Please enter three values: " << endl; cin >> v_1 >> v_2 >> v_3; cout << "\n\n"; cout << "The sum of these numbers is " << Do_Sum (v_1, v_2, v_3); cout << "\n\n"; break; } case 2: { cout << "Please enter three values: " << endl; cin >> v_1 >> v_2 >> v_3; cout << "\n\n"; cout << "The product of these numbers is" << Do_Product (v_1, v_2, v_3); cout << "\n\n"; break; } case 3: { cout << "Please enter three values: " << endl; cin >> v_1 >> v_2 >> v_3; cout << "\n\n"; cout << "The average of these numbers is " << Do_Average (v_1, v_2, v_3); cout << "\n\n"; break; } case 4: { cout << "Please enter three values: " << endl; cin >> v_1 >> v_2 >> v_3; cout << "\n\n"; Do_Sort (v_1, v_2, v_3); cout << v_1 << " " << v_2 << " " << v_3; cout << "\n\n"; break; } case 5: { option = 5; break; } default: { cout << "Please renter option: " << endl; cin >> option; } } } }//END OF MAIN float Do_Sum (float v_1, float v_2, float v_3) { float total = 0; total = (v_1 + v_2 + v_3); return total; }//END OF DO SUM float Do_Product (float v_1, float v_2, float v_3) { float product = 0; product = (v_1 * v_2 * v_3); return product; }//END OF DO PRODUCT float Do_Average (float v_1, float v_2, float v_3) { float average = 0; average = ((v_1 + v_2 + v_3) / 3); return average; }//END OF DO AVERAGE void Do_Sort (float& v_1, float& v_2, float& v_3) { if (v_2 < v_1) { swap(v_2, v_1); } else if (v_3 < v_1) { swap (v_3, v_1); } else if (v_3 < v_2) { swap (v_3, v_2); } else if (v_1 < v_1) { swap (v_1, v_3); } }//END OF SORT void Swap(int& u, int& v) { int temp; temp = u; u = v; v = temp; } //END OF SWAP