Program Screen Shot:


Program code to copy:
#include <iostream>
#include <cmath>
using namespace std;
const double pi = M_PI;
// --- Adding three new functions for calculating Surafce Area,
Volume & one for showing message
// --- Function prototypes
double sphere_surfaceArea(double);
double spehre_volume(double);
void messageSphere(double, double, double);
// --- changing structure name to 'Sphere' & with three variables, for "radius", "surfaceArea" & "volume" respectively
struct Sphere{
double radius;
double surfaceArea;
double volume;
};
int main(){
// --- Creating an instance of Sphere
Sphere s1 = {1, 0, 0};
// --- Taking radius as input from user
cout << "Please input a radius for your sphere:
";
cin >> s1.radius;
// --- We are calling the functions as arguments as
given in sample code
messageSphere(s1.radius,
sphere_surfaceArea(s1.radius),
spehre_volume(s1.radius));
return 0;
}
// --- Implementing all functions
double sphere_surfaceArea(double r){
return 4 * pi * r * r; // calculating
surface area
}
double spehre_volume(double r){
return (4.0/3.0) * pi * r * r * r; //
calculating volume
}
void messageSphere(double radius, double surfaceArea,
double volume){
cout << endl << "Sphere characteristics
using structures" << endl;
cout << "Radius: " << radius <<
endl
<< "Surface Area: " << surfaceArea
<< endl
<< "Volume: " << volume <<
endl;
}
Sample output:

------------------------------------------------------------------------------------------------------------------------
COMMENT DOWN FOR ANY
QUERIES..............................................
HIT A THUMBS UP IF YOU DO LIKE IT!!!
modify sample code from example two to calculate the surface area and volume of a sphere...
Need C++ Code (Please put //comments on there too) 1. Complete the following code: Design a class called Circle. The class should have an integer member variable named radius and three member functions; setRadius, getRadius, calArea; the functions' prototypes should be done inside the class declaration and the functions' definitions should come after the main function #include <iostream> using namespace std; const double PI = 3.14; // fill in the declaration of the class Circle here int main() { Circle...
C++ programming question will upvote
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...
c++ Please help! i keep getting an error message. I think my
main problem is not understanding the circle calculations function
and how both the area and the circumference is returned from the
function. I know & needs to be used, but I am unsure how to use
it.
Copy the following code and run it. You should break it into the following 3 functions getValidinput - which asks the user to enter the radius and then make sure that...
In C++ 9) (5 pts) Complete the following function that takes 3 arguments of a circle : - radius (input argument) - area (output argument, to be calculated) - circumference (output argument, to be calculated) All arguments are double type. If a radius is negative, the function returns false, otherwise it returns true. The function does only calculation, and does nothing else. Assume that all #include are already there // Fill in your Function prototype bool circleAreaAndCircumference ( _______,...
C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose we have the job to make a program that accepts a dinner reservation. The information collected will be the name of the customer, the date for the reservation, the time for the reservation (good choice for a hierarchical struct), the number in the party, email address (for updates) and phone number. Define a hierarchical structure for a dinner reservation that will contain the above...
Pure Abstract Base Class Project. Define a class called BasicShape which will be a pure abstract class. The class will have one protected data member that will be a double called area. It will provide a function called getArea which should return the value of the data member area. It will also provide a function called calcArea which must be a pure virtual function. Define a class called Circle. It should be a derived class of the BasicShape class. This...
C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream> using namespace std; void fun1(int radius) { /* dynamic memory management */ double * dmptr; double circumference; /* add the code below to: - allocate a memory location for a double and nameless variable in heap and assign its address to the pointer - assign 3.14 to the variable in heap via the pointer....
Please upload screenshots of the code. Thank you!
P1 - Circle Area and Circumference functions.cpp, functions.h, P1.cpp The user enters 3 floating-pointer numbers which correspond to 3 radi. Store these numbers in an array. Then, define and prototype a function void area and cireffloat* area, float circumference, float array) which takes as input the array of circumferences of circles with the input radii. Think about why we need to pass pointers for both the area and the circumference variables. radii...
Help please: A Modular Function: You must rewrite the code to use a modular function that can be used again by other modules. Your main program will call the function and pass the variables by value. Your function will take the appropriate action and return the required value . (Hint you will use additional variables in your revised code). The called function must be able to accept the data passed to it by the function doing the calling. Only after...