1. // Introduction
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. // Setup
  8.  
  9. // Use
  10.  
  11. int findSufaceArea()
  12. {
  13. // Declare variables
  14.  
  15. // Dimensions
  16. float l, h, w;
  17. // Surface Areas
  18. float a, b, c, d;
  19.  
  20. // Get values
  21. cout << "Enter length (l): " << endl;
  22. cin >> l ;
  23. cin.ignore();
  24.  
  25. cout << "Enter width (w): " << endl;
  26. cin >> w ;
  27. cin.ignore();
  28.  
  29. cout << "Enter height (h): " << endl;
  30. cin >> h ;
  31. cin.ignore();
  32. // Do math
  33. // 2lw
  34. a = l * w * 2;
  35. // 2wh
  36. b = w * h * 2;
  37. // 2lh
  38. c = l * h * 2;
  39. //a+b+c
  40. d = a+b+c;
  41. cout << "Total Surface Area of your Rectangular Prism is: " << d << endl;
  42. // Do again
  43. cout << "Do again? (y or n)" << endl;
  44. string f;
  45. cin >> f;
  46. cin.ignore();
  47. if (f == "y"){
  48. findSufaceArea();
  49. }
  50. else if (f == "Y"){
  51. findSufaceArea();
  52. }
  53. string g;
  54. cout << "Are you sure? (y or n)" << endl;
  55. cin >> g;
  56. cin.ignore();
  57. if (g == "n"){
  58. findSufaceArea();
  59. }
  60. else if (g == "N"){
  61. findSufaceArea();
  62. }
  63. return 0;
  64. }
  65.  
  66. int main()
  67. {
  68. findSufaceArea();
  69. return 0;
  70. }