Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- //basics that we use in every program
- using namespace std;
- // the constant you asked for
- const double PI = 3.141592;
- // my function prototypes (looked into example and it recommended that we switch some of the data types so they dont overlap)
- void getData(double& base, double& height);
- void getData(int& radiusA, double& radiusB);
- void printData(double& rec_area, double &elli_area);
- //main function
- int main()
- {
- //variables
- double base;
- double height;
- double radiusA;
- double radiusB;
- double rec_area;
- double elli_area;
- //prompting user
- cout << " For the rectangle " << endl;
- // calling my void function
- getData(base, height);
- cout << " for elipse " << endl;
- getData(radiusA, radiusB);
- // calculating results input by user
- rec_area = base * height;
- elli_area = PI * radiusA * radiusB;
- // calling the print data function that shows results
- printData(rec_area, elli_area);
- system("pause");
- return 0;
- }
- // the actual functions of the prototypes
- void getData(double& base, double& height)
- {
- cout << " Enter base and height now " << endl;
- cin >> base;
- cin >> height;
- }
- // at first i only had one prototype so I feel like I did it wrong by seperating them into multiple
- void getData(int& radiusA, double& radiusB)
- {
- cin >> radiusA;
- cin >> radiusB;
- }
- // this one did need another body since its PRINTdata not GET data
- void printData(double& rec_area, double& elli_area)
- {
- cout << fixed << setprecision(1.0);
- cout << " the area of the rectangle is " << rec_area << endl;
- cout << " the area of the ellipse is " << elli_area << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement