Quickie C++ query

Sharky Forums


Results 1 to 2 of 2

Thread: Quickie C++ query

  1. #1
    Hammerhead Shark Shadowfire's Avatar
    Join Date
    Nov 2001
    Location
    Pleasanton, CA
    Posts
    2,614

    Post Quickie C++ query

    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

    FX-62 / MSI K9N PLATINUM SLI / 2x1GB Patriot DDR2 800 / XFX 7600GT
    IBM T60 / 1.83 GHz Core Duo / 1.5 GB DDR2 667 MHz / 80 GB SATA HD / ATi X1300 64 MB / Fingerprint reader!!!



    My Heatware!!! w00t w00t, got lots of evals now!

    Proud Private Shadowfire of The Cooler's Guild


  2. #2
    Hammerhead Shark Shadowfire's Avatar
    Join Date
    Nov 2001
    Location
    Pleasanton, CA
    Posts
    2,614

    Post

    NVM Peeps, i already got me a nice continuation function Thanks anyway

    ------------------
    Been there, done that, don't remember it....
    My Fruit Basket

    FX-62 / MSI K9N PLATINUM SLI / 2x1GB Patriot DDR2 800 / XFX 7600GT
    IBM T60 / 1.83 GHz Core Duo / 1.5 GB DDR2 667 MHz / 80 GB SATA HD / ATi X1300 64 MB / Fingerprint reader!!!



    My Heatware!!! w00t w00t, got lots of evals now!

    Proud Private Shadowfire of The Cooler's Guild


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •