Geometric formulas to functions.

I need help on a program that tells me to convert the geometric formulas to a function to return the results. I need to use the following:

// Return the Circumference of Circle
double CCircle(double radius)

// Return the Area of Circle
double ACircle(double radius)

// Return the Surface Area of Sphere
double SASphere(double radius)

// Return the Volume of Sphere
double VSphere(double radius)

// Return the Perimeter of Square
double PSquare(double side)

// Return the Area of Square
double ASquare(double side)

// Return the Surface Area of Cube
double SACube(double side)

// Return the Volume of Cube
double VCube(double cube)

// Return the Perimeter of Rectangle
double P Rectangle(double sideA, double sideB)

// Return the Area of Rectangle
double ARectangle(double sideA, double sideB)

// Return the Surface Area of Rectangular Prism
double SARPrism(double sideA, double sideB, double sideC)

// Return the Volume of Rectangular Prism
double VRPrism(double sideA, double sideB, double sideC)

// Return the Surface Area of Cylinder
double SACylinder(double radius, double height)

// Return the Volume of Cylinder
double VCylinder(double radius, double height)

// Return the Surface Area of Cone
double SACone(double radius, double height)

// Return the Volume of Cone
double VCone(double radius, double height)

Thanks in advance.
closed account (48T7M4Gy)
What sort of help do you need?
Write a test program that invokes those functions to display a table.
closed account (48T7M4Gy)
So where are you having difficulty with doing that?
Yes I am sorry I am just asking for some help to understand it better.
This is what I have so far...

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

double SASphere(double radius)
{
const int PI = 3.1415;
double r = 0.0;
double CCircle = 0.0;
CCircle = 2 * PI * r;
double ACircle = 0.0;
ACircle = PI * r;

}
double VSphere(double radius);
double PSquare(double side);
double ASquare(double side);
double SACube(double side);
double VCube(double cube);
double PRectangle(double sideA, double sideB);
double ARectangle(double sideA, double sideB);
double SARPrism(double sideA, double sideB, double sideC);
double VRPrism(double sideA, double sideB, double sideC);
double SACylinder(double radius, double height);
double VCylinder(double radius, double height);
double SACone(double radius, double height);
double VCone(double radius, double height);

int main ()
{
cout << setw(2) << "CCircle " << setw(10) << "Acircle " << endl;

double radius = 1; double area = 1;

cout << setw(1) << CCircle(area) << setw(1) << endl;

return 0;
}
Thanks. Help will be appreciated but I will continue to try to figure this out.
closed account (48T7M4Gy)
Maybe use this as a pattern. You probably don't have to give alternatives. Also, look up the formulae on line for the various geometric properties if you don't know them. There are plenty of sites, including wikipedia.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

const double PI = 3.1415; // Put this here as a global constant (cmath also has a built in PI)
                          // Also PI is double not integer

//JUST COPY FROM PROBLEM, REMOVE VARIABLE NAMES & PUT THEM (PROTOTYPES) HERE:

// Return the Circumference of Circle
double CCircle(double);

// Return the Area of Circle
double ACircle(double);

// Return the Surface Area of Sphere
double SASphere(double);

int main ()
{
    // Test 1:
    double radius = 1;
    double circumference = CCircle(radius);
    double circle_area = ACircle(radius);
    
    cout << setw(2) << "Radius = " << radius << " CCircle = " << setw(10) << circumference << endl;
    
    // Another way
    cout << setw(2) << "Radius = " << radius << " CCircle = " << setw(10) << CCircle(radius) << endl;
    
    // Yet another way
    cout << setw(2) << "Radius = 1  CCircle = " << setw(10) << CCircle(1) << endl;
    
    //Test 2
    cout << setw(2) << "Area = " << radius << " ACircle = " << setw(10) << circle_area << endl;
    
    return 0;
}

//FUNCTION IMPLEMENTATIONS GO HERE AFTER MAIN
//USE COPY AND PASTE AS A START

// Return the Circumference of Circle
double CCircle(double aRadius)
{
    return 2 * PI * aRadius;
}

// Return the Area of Circle
double ACircle(double aRadius)
{
    double area = PI * aRadius * aRadius;
    return area;
}

double SASphere(double aRadius)
{
    double area = 0;
    area = 4 * PI * aRadius * aRadius;
    return area;
}
Alright thank you so much I will search up the formulas. I appreciate your help
closed account (48T7M4Gy)
My pleasure. Please take note of the homework comment I made on your other thread. It's your turn now. :)
Last edited on
Topic archived. No new replies allowed.