Hi,
My menu driven program that repeatedly calculates and prints the diameter of, circumference or area of circle, given the radius,
is not doing what I want it to do...
Can code doc / code friend point out how to make it work?
Thanks
Code:#include<iostream> using std::cout; using std::cin; using std::endl; #include <iomanip> using std::setprecision; int main() { double Diameter, Area, Circumference, radius; char D=0, A=0, C=0, X=0, input=0; cout << "Please pick an option: " << endl << "Calculate the diameter of the circle: 'D' " << endl << "Calculate the area of the circle: 'A' " << endl << "Calculate the circumference: 'C' " << endl << "Exit the program: 'X' " << endl; cin >> ( D || A || C || X ) cout << setprecision ( 2 ) { if ( input == D ){ cout << "Enter the lenght of the radius: " << endl; cin >> radius; Diameter = 2* radius ; cout << " The diameter of circle with radius " << radius << "is " << Diameter << endl; } if ( input == A ) { cout << "Enter the lenght of the radius: " << endl; cin >> radius; Area = 3.14 * radius * radius ; cout << " The area of cirlce with radius " << radius << "is" << Area << endl; } if ( input == C) { cout << "Enter the lenght of radius: " << endl; cin >> radius; Circumference = 2 * 3.14 * radius ; cout << "The circumference of the circle with radius " << radius << "is " << Circumference << endl; } if ( input == X) cout << "Good bye" << endl; } return 0; }



LinkBack URL
About LinkBacks


