Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Introduction
- #include <iostream>
- #include <string>
- using namespace std;
- // Setup
- // Use
- int findSufaceArea()
- {
- // Declare variables
- // Dimensions
- float l, h, w;
- // Surface Areas
- float a, b, c, d;
- // Get values
- cout << "Enter length (l): " << endl;
- cin >> l ;
- cin.ignore();
- cout << "Enter width (w): " << endl;
- cin >> w ;
- cin.ignore();
- cout << "Enter height (h): " << endl;
- cin >> h ;
- cin.ignore();
- // Do math
- // 2lw
- a = l * w * 2;
- // 2wh
- b = w * h * 2;
- // 2lh
- c = l * h * 2;
- //a+b+c
- d = a+b+c;
- cout << "Total Surface Area of your Rectangular Prism is: " << d << endl;
- // Do again
- cout << "Do again? (y or n)" << endl;
- string f;
- cin >> f;
- cin.ignore();
- if (f == "y"){
- findSufaceArea();
- }
- else if (f == "Y"){
- findSufaceArea();
- }
- string g;
- cout << "Are you sure? (y or n)" << endl;
- cin >> g;
- cin.ignore();
- if (g == "n"){
- findSufaceArea();
- }
- else if (g == "N"){
- findSufaceArea();
- }
- return 0;
- }
- int main()
- {
- findSufaceArea();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement