Advertisement
bbg6

lab 7 part A

Apr 11th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. //basics that we use in every program
  4. using namespace std;
  5. // the constant you asked for
  6. const double PI = 3.141592;
  7. // my function prototypes (looked into example and it recommended that we switch some of the data types so they dont overlap)
  8. void getData(double& base, double& height);
  9. void getData(int& radiusA, double& radiusB);
  10. void printData(double& rec_area, double &elli_area);
  11.  
  12. //main function
  13. int main()
  14. {
  15.     //variables
  16.     double base;
  17.     double height;
  18.     double radiusA;
  19.     double radiusB;
  20.     double rec_area;
  21.     double elli_area;
  22.     //prompting user
  23.     cout << " For the rectangle " << endl;
  24.     // calling my void function
  25.     getData(base, height);
  26.     cout << " for elipse " << endl;
  27.     getData(radiusA, radiusB);
  28.     // calculating results input by user
  29.     rec_area = base * height;
  30.     elli_area = PI * radiusA * radiusB;
  31.     // calling the print data function that shows results
  32.     printData(rec_area, elli_area);
  33.    
  34.  
  35.  
  36.     system("pause");
  37.     return 0;
  38.  
  39.  
  40. }
  41.  
  42. // the actual functions of the prototypes
  43. void getData(double& base, double& height)
  44. {
  45.     cout << " Enter base and height now " << endl;
  46.     cin >> base;
  47.     cin >> height;
  48.  
  49. }
  50. // at first i only had one prototype so I feel like I did it wrong by seperating them into multiple
  51. void getData(int& radiusA, double& radiusB)
  52. {
  53.     cin >> radiusA;
  54.     cin >> radiusB;
  55. }
  56. // this one did need another body since its PRINTdata not GET data
  57. void printData(double& rec_area, double& elli_area)
  58. {
  59.     cout << fixed << setprecision(1.0);
  60.     cout << " the area of the rectangle is " << rec_area << endl;
  61.     cout << " the area of the ellipse is " << elli_area << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement