Click to See Complete Forum and Search --> : Quickie C++ query


Shadowfire
12-10-2001, 10:50 AM
Me needs to have a Continue/Quite option on the next code, I.E. if i key in "C" tha proggie will restart, but if i key in anything else, it will stop. Feel free to modify the code as you wish...

//Gene Romm
//BHC Program - my ingenius creation!

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

const double PI=3.1415926;

float polarX(float , float);
float polarY(float , float);


int main(void)
{
float radius;
float diameter;
int holes;
cout<<"Hello, and welcome to my BHC program created by me!\n";
cout<<"Please enter the diameter of the circle:\n";
cin>>diameter;

radius=diameter/2;

cout<<"Now I need to know the amount of holes you wish to have:\n";
cin>>holes;
cout<<"The coordinates are shown as following: (X,Y)\n";
for (float b=360.0; b>0.0; b-=(360.0/holes) )
{
cout
<<"** "<<
setprecision(3) <<
setiosflags( ios::fixed) <<
setw(7) << polarX(radius, b) <<" , "<<
setw(7) << polarY(radius, b) <<" **\n";
}

return 0;


}

float polarX(float radius, float angle)
{
float coordinates = cos( (angle / 180) * PI);
if ( (-0.001 < coordinates ) && ( coordinates < 0.001) )
coordinates = 0;

return radius * coordinates;
};

float polarY(float radius, float angle)
{
float coordinates = sin( (angle / 180) * PI);

if ( (-0.001 < coordinates ) && ( coordinates < 0.001) )
coordinates = 0;

return radius * coordinates;
};


------------------
Been there, done that, don't remember it....
My Fruit Basket (http://www.anandtech.com/myanandtech.html?member=73946)

Shadowfire
12-10-2001, 11:05 AM
NVM Peeps, i already got me a nice continuation function http://www.sharkyforums.com/ubb/smile.gif Thanks anyway http://www.sharkyforums.com/ubb/smile.gif

------------------
Been there, done that, don't remember it....
My Fruit Basket (http://www.anandtech.com/myanandtech.html?member=73946)