Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. const double pi = 3.14159;
  6.  
  7.  
  8. int main()
  9. {
  10. double area, circum, diam, rad;
  11.  
  12. cout << "Enter radius : " << flush;
  13. cin >> rad;
  14. string ynarea;
  15. cout << "Print Area? (y/n) " << flush;
  16. cin >> ynarea;
  17. string yncircum = "";
  18. cout << "Print Circumference? (y/n) " << flush;
  19. cin >> yncircum;
  20. string yndiam = "";
  21. cout << "Print Diameter? (y/n) " << flush;
  22. cin >> yndiam;
  23.  
  24. area = pi * rad * rad;
  25. circum = pi * rad * 2.0;
  26. diam = rad * 2.0;
  27.  
  28. if( ynarea == "y" || "Y" )
  29. {
  30. cout << "Area is " << area << endl;
  31. }
  32. else
  33. {
  34. cout << endl;
  35. }
  36. if( yncircum == "y" || "Y" )
  37. {
  38. cout << "Circumference is " << circum << endl;
  39. }
  40. if( yndiam == "y" || "Y" )
  41. {
  42. cout << "Diameter is " << diam << endl;
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement