Hi all,
i have got a complex assignment. below is what the assignment talk about
1. write a program to calculate the volume of a sphere with a radius, r. The volume is given by this formula
Volume = 4πr3
3
Answer the following questions:
a) Write complete program requirements specification for this problem.
b) Determine the output required by the program.
c) Determine how many inputs the program will have.
d) What is the C++ formula for converting the input items into output items.
e) Do a hand calculation for the given input value.
f) Provide a solution algorithm for this problem
g) Code the program in C++
This is the codes that i have so far, but its giving me a little bit of headache with errors
#include <iostream>
#include <cmath>
using namespace std;
int main(){
//Input radius, volume, initialValue, increment, ending Value,
double x, volume, initialRadius, increment, endingRadius, radius;
#define PI 3.14159
//Output Volume of Sphere, Radius,
cout<<" Please input the initial radius of the sphere: "<<endl;
cin>>initialRadius;
cout<<"Please input your increment value: "<<endl;
cin>>increment;
cout<<"Please input the final radius of the sphere."<<endl;
cin>>endingRadius;
for (x=initialRadius;x<=endingRadius; x = x + increment)
{ radius = x;
volume=4/3.0*PI*pow(radius,3);
cout<<"The Volume of a sphere with a radius of "<<radius<<" mm is "<<volume<<" mm3."<<endl;
}
cin.get();
return 0;
}
The code is not totally running due to errors. i need a little bit of correction. thank you.