hey guys so I'm having this problem i don't fully understand c++ but I'm trying, so what I'm trying to do is a program that where you could calculate the x and y co-ordinates, as well as the angle, for the holes of a circular bolt pattern.

User input: number of points, diameter, x co-ordinate of center, y co-ordinate of center.

this is what i got so far but im having problems with the loop:

#include<iostream>

#include<iomanip>

#include<cmath>

using namespace std;

int main ()

{

//variables

float x, y , Diameter_of_circle, points_loc;

float degrees, x2, y2, radius;

int points;

cout<<setprecision(2); //specifies the number of digits after decimal point

cout<<fixed<<showpoint;

cout<< "Enter the number of points: ";

cin>> points;

cout<< "Enter the Diameter of the circle: ";

cin >> Diameter_of_circle;

cout<< "Location of circle center on x: " ;

cin>> x;

cout<< "Location of circle center on Y: " ;

cin>> y;

cout<< endl;

//equations

degrees= 6.2831*(180/M_PI);

points_loc= (6.2831*(160/M_PI))/ points;

radius= (Diameter_of_circle/2);

x2 = x+ (radius*cos((degrees)));

y2 = y+ (radius*sin((degrees)));

//output

for ( int i=0; i< points; i*=points)

{

cout<< "At: "; cout<< setprecision(2)<< points_loc; cout<<" X: " << cout<< x2;

cout<< " Y: " << cout << y2;

cout<< endl;

}

system("Pause");

return 0 ;

}

User input: number of points, diameter, x co-ordinate of center, y co-ordinate of center.

this is what i got so far but im having problems with the loop:

#include<iostream>

#include<iomanip>

#include<cmath>

using namespace std;

int main ()

{

//variables

float x, y , Diameter_of_circle, points_loc;

float degrees, x2, y2, radius;

int points;

cout<<setprecision(2); //specifies the number of digits after decimal point

cout<<fixed<<showpoint;

cout<< "Enter the number of points: ";

cin>> points;

cout<< "Enter the Diameter of the circle: ";

cin >> Diameter_of_circle;

cout<< "Location of circle center on x: " ;

cin>> x;

cout<< "Location of circle center on Y: " ;

cin>> y;

cout<< endl;

//equations

degrees= 6.2831*(180/M_PI);

points_loc= (6.2831*(160/M_PI))/ points;

radius= (Diameter_of_circle/2);

x2 = x+ (radius*cos((degrees)));

y2 = y+ (radius*sin((degrees)));

//output

for ( int i=0; i< points; i*=points)

{

cout<< "At: "; cout<< setprecision(2)<< points_loc; cout<<" X: " << cout<< x2;

cout<< " Y: " << cout << y2;

cout<< endl;

}

system("Pause");

return 0 ;

}

closed account (*Dy7SLyTq*)

first im pretty sure fixed is a function and what is show point? whats M_PI? at the for loop why are you multiplying i by points? it will only loop once

M_PI is how the system uses the function of pi instead of declaring it as a variable, show point as far as i know is just to show the point in a decimal answer so it comes out as for example 9.32 and i was multiplying by points so it could change the angle but yup it was probably a mistake. how could you do it so it loops = the number of points

Topic archived. No new replies allowed.