Feb 10, 2016 at 7:20pm UTC
So I need to write a program with menu, but the menu needs to loop after a certain input is entered. I'm think a do-while loop would work but I am unsure of how to implement it into the quit part of the menu. Any suggestions?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cctype>
using namespace std;
int main()
{
double radius, error;
char method_choice = 'x' ;
char rerun_choice = 'z' ;
cout << showpoint << fixed;
cout << setprecision(4);
radius = 0;
cout << "Compute Area of a Circle" << endl << endl;
cout << "Enter Radius: " ;
cin >> radius;
cout << "Enter Acceptable Error: " ;
cin >> error;
cout << "Select a method:" << endl;
cout << "A. Blah" << endl;
cout << "B. Blah Blah" << endl;
cout << "C. Blah Blah Blah" << endl;
cout << "Enter Choice: " ;
cin >> method_choice;
method_choice = toupper(method_choice);
switch (method_choice)
{
case 'A' :
//Math Equations
break ;
case 'B' :
//Math Equations
break ;
case 'C' :
//Math Equations
break ;
default :
cout << "Error" << endl;
}
cout << endl << "Quit?" << endl;
cout << "Y. Yes" << endl;
cout << "N. No" << endl;
cout << "Enter Choice: " ;
cin >> rerun_choice;
rerun_choice = toupper(rerun_choice);
switch (rerun_choice)
{
case 'Y' :
break ;
case 'N' :
break ;
default :
cout << "Invalid choice" << endl;
}
}
Last edited on Feb 11, 2016 at 8:57pm UTC
Feb 11, 2016 at 8:59pm UTC
How can I add my switch to ask if the user wants to rerun or quit though?