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

Write a C++ program that calls a function named calcul8, to determine the volume

ID: 3832223 • Letter: W

Question

Write a C++ program that calls a function named calcul8, to determine the volume of a sphere and the area of a circle for a given radius that varies from 1 to 10 in increments of 0.5. the array "data" must contain the values of the radius in the first column, values for the volumes of the spheres in the second column and the values for the areas of the circles in the third column. Requirements: The increment of 0.5 must be a global variable, and must be named "inc". "inc" must be initialized in the main function A function prototype must be used for calcul8 The main function must: call the calcul8 function populate the array "data" with values of the radius using a repetition statement contain all output filestream objects instantiate the string object named MyString the function call to calcul8 must assign the return value to the object named 'MyString" use a nested repetition statement to display the array values on the monitor. display the message returned by the function cakul8 at the end of the program The calcul8 function must: have one pass by reference argument which must be a two-dimensional array named "data." have two pass by value arguments. The beginning radius, r_beg and the ending radius, r_end. populate the values for the volume of the spheres and the area of the circles in the "data" array using repetition statements. Return these values through the argument list. use the pow function cannot have any output file stream objects instantiate the object named Message with an initial string of "We are finished with the program" return by value the string object named "Message" The output must have the following characteristics: The output must be displayed on the monitor in three columns. The column headings must be Radius, Volume and Area. All output data must have three decimal places. All numerical output must use the three manipulators that have been required throughout the entire semester. The equations are: V = 4/3 pir^3 A = pir^2

Explanation / Answer

PROGRAM CODE:

#include <iostream>
#include<cmath>
using namespace std;

double inc;

string calcul8(double*[], double , double );


int main() {
   inc = 0.5;
   double *data[3] = {{}};
   string MyString = calcul8(data, 2.0, 4.0);
   for(int i=0; i<5; i++)
   {
       cout<<data[i][0]<<" "<<data[i][1]<<" "<<data[i][2]<<endl;
   }
   cout<<MyString<<endl;
   return 0;
}

string calcul8(double *data[], double r_beg, double r_end)
{
   int counter = 0;
   string Message = "We are finished with the program";
   for(double i=r_beg; i<=r_end; i= i+inc)
   {
       data[counter][0] = i;
       data[counter][1] = (4.0/3.0)*3.14*pow(i,3);
       data[counter][2] = 3.14*pow(i,2);
       counter++;
   }
   return Message;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote