Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

and also can i copy and past ((prgramming C++)) Write a program that 1) calculat

ID: 3824629 • Letter: A

Question

and also can i copy and past ((prgramming C++))

Write a program that 1) calculates perimeter/circumference and area for specific geometric plane figures and 2) calculates the volume and surface area of specific geometric solids. The program should take input from the keyboard and keep track of the units of measurement. It should also have a function for each figure. Answers should be to nearest 100th of a unit (2 decimal places). The figures and shapes are listed below: Circular Figures (OUTPUT Perimeter and Area or surface area and volume as appropriate.) 1. Circle (INPUT radius) 2. Sphere (INPUT radius) 3. Cylinder (INPUT radius and height) 4. Cone (INPUT radius and height) 5. Ellipse (INPUT major and minor axes) The program should permit the user to keep going or terminate after each calculation is made.

Explanation / Answer

Here is the code for you:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void circle(double radius, double& area, double& perimeter)
{
    area = M_PI * radius * radius;
    perimeter = 2 * M_PI * radius;
}
void sphere(double radius, double& volume, double& surfaceArea)
{
    volume = 4/3.0 * M_PI * radius * radius * radius;
    surfaceArea = 4 * M_PI * radius * radius;
}
void cylinder(double radius, double height, double& volume, double& surfaceArea)
{
    volume = M_PI * radius * radius * height;
    surfaceArea = 2 * M_PI * radius * height + 2 * M_PI * radius * radius;
}
void cone(double radius, double height, double& volume, double& surfaceArea)
{
    volume = M_PI * radius * radius * height / 3;
    surfaceArea = M_PI * radius * (radius + sqrt(height * height + radius * radius));
}
void ellipse(double major, double minor, double& area, double perimeter)
{
    area = M_PI * major * minor;
    perimeter = 2 * M_PI * sqrt((major * major + minor * minor) / 2);
}
int main()
{
    double radius, area, perimeter, volume, surfaceArea, height, major, minor;
    int choice;
    cout << "1. Circle." << endl;
    cout << "2. Sphere." << endl;
    cout << "3. Cylinder." << endl;
    cout << "4. Cone." << endl;
    cout << "5. Ellipse." << endl;
    cout << "Enter your choice: ";
    cin >> choice;
    switch(choice)
    {  
       case 1:   cout << "Enter the radius: ";
               cin >> radius;
               circle(radius, area, perimeter);
               cout << "The area of the circle is: " << fixed << setprecision(2) << area << endl;
               cout << "The perimeter of the circle is: " << fixed << setprecision(2) << perimeter << endl;
               break;
       case 2:   cout << "Enter the radius: ";
               cin >> radius;
               sphere(radius, volume, surfaceArea);
               cout << "The volume of the sphere is: " << fixed << setprecision(2) << volume << endl;
               cout << "The surfaceArea of the sphere is: " << fixed << setprecision(2) << surfaceArea << endl;
               break;
       case 3: cout << "Enter the radius: ";
               cin >> radius;
               cout << "Enter the height: ";
               cin >> height;
               cylinder(radius, height, volume, surfaceArea);
               cout << "The volume of the cylinder is: " << fixed << setprecision(2) << volume << endl;
               cout << "The surfaceArea of the cylinder is: " << fixed << setprecision(2) << surfaceArea << endl;
               break;
       case 4: cout << "Enter the radius: ";
               cin >> radius;
               cout << "Enter the height: ";
               cin >> height;
               cone(radius, height, volume, surfaceArea);
               cout << "The volume of the cone is: " << fixed << setprecision(2) << volume << endl;
               cout << "The surfaceArea of the cone is: " << fixed << setprecision(2) << surfaceArea << endl;
               break;
       case 5: cout << "Enter the major axis length: ";
               cin >> major;
               cout << "Enter the minor axis length: ";
               cin >> minor;
               ellipse(major, minor, area, perimeter);
               cout << "The area of the ellipse is: " << fixed << setprecision(2) << area << endl;
               cout << "The perimeter of the ellipse is: " << fixed << setprecision(2) << perimeter << endl;
               break;
       default: cout << "Invalid selection." << endl;
    }
}