Yyyyyyyeah..... I'm like brand new at C++, I started yesterday, so far this is my most advanced program:
Code:
#include <iostream>
#include <math.h>
using namespace std;
float r, h, s;
int n;
int main()
{
int input;
cout<<"\n\n ============ Welcome to the Round shapes program ============\n\n\n";
while (input != 4){
cout<<" 1. Circle\n";
cout<<" 2. Sphere\n";
cout<<" 3. Cone\n";
cout<<" 4. Exit\n\n\n";
cout<<"Selection: ";
cin>> input;
switch ( input ) {
case 1:
float circle(float r);
cout<<"What is the radius of the circle?"; cin>> r ; cout<<">>>\n\n";
cout<<"The circumference of the circle is: "<< (2 * r) * 3.14159265358979323846 <<"\n\n";
cout<<"The area of the circle is: "<< 3.14159265358979323846 * (r * r) <<"\n\n";
break;
case 2:
float circle(float r);
cout<<"What is the radius of the circle?"; cin>> r ; cout<<">>>\n\n";
cout<<"The surface area of the sphere is: "<< 4 * 3.14159265358979323846 * (r*r*r) <<"\n\n";
cout<<"The volume of the sphere is: "<< (4 * 3.14159265358979323846)/3 * (r*r*r) <<"\n\n";
break;
case 3:
float cone(float r, float h, float s);
cout<<"What is the radius of the base? >>>"; cin>> r ; cout<<"\n\n";
cout<<"What is the height of the cone? >>>"; cin>> h ; cout<<"\n\n";
s = sqrt(r * r + h * h);
cout<<"The area of the base is: "<< 3.14159265358979323846 * (r * r) <<"\n\n";
cout<<"The surface area of the triangle is: "<< 3.14159265358979323846 * r * (r+s) <<"\n\n";
cout<<"The height of the sloped side is: "<< s <<"\n\n";
cout<<"The volume of the cone is: "<< 3.14159265358979323846 * r * r * h/3 <<"\n\n";
break;
case 4:
cout<<"Press \"Enter\" to close...\n";
break;
default:
cout<<"Error, bad input, quitting\n";
break;
}
cout<<"Press \"Enter\" to continue on.\n\n";
cin.get();
cin.get();
}
}
-----Edit-----
Don't you just love how I took pi to 21 digits? lol Overkill much?