The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 ViewsJust made a C++ prog that takes a number and finds the circumfrence, surface area, area, and volume of a sphere with that raduis. However im not sure if these equasions work correctly. I forgot the forumlas for finding these measurments so i had to look them up. However doing them on paper seems to be easier than doing them in C++. I have gotton some very odd measurments. heres the program.
#include<iostream>
using namespace std;
int main() {
double radius, circum, SA, vol, area, pie;
pie = 3.14;
cout << "Enter a radius: ";
cin >> radius;
cout << endl;
//circumference
circum = pie * (2 * radius);
cout << "Circumference: " << circum << endl;
//surface area
SA = 4 * pie * radius;
SA = SA * SA;
cout << "Surface area: " << SA << endl;
//Volume
vol = 4 * pie * radius;
vol = (vol * vol * vol) / 3;
cout << "Volume: " << vol << endl;
//Area
area = pie * radius * radius;
cout << "Area: " << area << endl;
fflush( stdin );
cin.get();
return 0;
}
// MustyWindows - Jump Through The Windows
// AmpFusion - Where Underground Becomes Mainstream
Neo Enterprise Technologies Coming soon.
At 7/9/05 09:04 AM, Inglor wrote: it's spelled "PI" not pie :P
That isnt by biggest problem. Im asking about the equasions. If a variable is mispelled, so what at this point.
// MustyWindows - Jump Through The Windows
// AmpFusion - Where Underground Becomes Mainstream
Neo Enterprise Technologies Coming soon.
I see you're playing with the HTS challenges I gave you. Anyway, what you may want to do is include <math>. That lib includes a const double value of pie. Just test the formula's on paper and then in the program and see if it works. I'll post my code later if you wish.
Stuff like this is much easier in Python:
def getFacts():
pi = 3.141592
while ( 1 ):
r = raw_input( "Enter the radius of a sphere: " )
try:
r = float( r )
break
except:
print "Try entering a number next time..."
print
print "The circumference is:", 2 * pi * r
print "The volume is:", 4.0 / 3 * pi * r * r * r
print "The surface area is:", 4 * pi * r * r
k i did
#include <math.h>
#define PI 3.1415926535
at the top of my program and removed pie from my program and used PI
I havnt tested these on paper yet. but i would like to ask what the hell this run means:
<--start run
Enter a radius: 500
Circumfrence: 3141.59
Surface area: 3.94784e+007
Volume: 8.26834e+010
Area: 785398
end run-->
Is that saposed to be C++'s scientific notation or somthing?and if so how do i
i) read it (personally, not the program) as a hole number? Im quite good with scientific notations but i dont know what is what in that reading.
ii) make the program show a hole number instead of a scientific notation?
ill try some of these on paper now and see what result i get.
// MustyWindows - Jump Through The Windows
// AmpFusion - Where Underground Becomes Mainstream
Neo Enterprise Technologies Coming soon.
At 7/9/05 10:56 AM, Begoner wrote: Stuff like this is much easier in Python:
It's the same thing, just depends on how you write it. This write decided to save computations into a value and display the value. In your code, you just directly displayed the final computation of the equation and didn't save it to a variable. So to say that it is much easier is pretty much useless, because it achieved the specified task in a different way.
At 7/9/05 12:07 PM, Ravens_Grin wrote:At 7/9/05 10:56 AM, Begoner wrote: Stuff like this is much easier in Python:It's the same thing, just depends on how you write it. This write decided to save computations into a value and display the value. In your code, you just directly displayed the final computation of the equation and didn't save it to a variable. So to say that it is much easier is pretty much useless, because it achieved the specified task in a different way.
I'm saying that Python is much more usefu and easier to codel for stuff like this, not that it's shorter.
At 7/9/05 11:31 AM, BulletProof57 wrote: Enter a radius: 500
Circumfrence: 3141.59
Surface area: 3.94784e+007
Volume: 8.26834e+010
Area: 785398
end run-->
i) read it (personally, not the program) as a hole number? Im quite good with scientific notations but i dont know what is what in that reading.
ii) make the program show a hole number instead of a scientific notation?
i) Volume, for instance, is the same as 8.26834*10^10 or 82,683,400,000. "e+XXX" is the same as "10 to the power od XXX"
ii) You could always do it yourself by turning the result into a string, truncatiing the e+XXX portion, and move the decimal place XXX places right, inserting zeroes when necessary.
I see you're playing with the HTS challenges I gave you. Anyway, what you may want to do is include <math>.
it's <cmath>!
bulletproof 57, make those SA, radius etc. variables to long long double, that can hold BIG numbers, then that inputting 500 should give clear results.
Oh, and don't use math.h, if you don't have like some 10 year old compiler, use <cmath>
Ermm heres how i did it.
#include <iostream>
using namespace std;
int main() {
int rad;
double pi = 3.1415;
cout<<"Circle Stats \n\n";
cout<<"Enter a radius: ";
cin>>rad;
cin.ignore();
cout<<"\nThe area of a circle with radius "<< rad << " is: \t"<< pi*rad*rad << endl;
cout<<"The circumference of a circle with radius "<< rad << " is: \t"<< rad*2*pi <<endl;
cout<<"The surface area of a sphere with radius "<< rad << " is: \t"<< 4*pi*rad*rad <<endl;
cout<<"The volume of a sphere with radius "<< rad << " is: \t"<< (4/3)*pi*rad*rad*rad <<endl;
cin.get();
return 0;
}
At 7/10/05 05:12 AM, --Amish-- wrote: Ermm heres how i did it.
And guess who gave him the link too.......... :p
How's the FT project?
Also, try rounding, 3.141592635 to 3.14159264 that way if you com;ile it, you an get it to work with most Texas Instruments.
At 7/10/05 12:39 PM, imtheawesomest wrote: lol wut r we talking about???????????
Just leave, please. You offer nothing to the conversation because you have no idea as to what's going on. At least learn the basics of one or more langauges before you return to just chat.
To Craige, that's neat. =)