
Taylor C.
asked 12/12/19How do you write a program using Javafx that takes a single, positive integer, and n as a command-line argument? The program should then plot n evenly spaced points around a circle.
1 Expert Answer

Patrick B. answered 12/13/19
Math and computer tutor/teacher
class CirclePoints
{
private int N;
private double angleTheta;
CirclePoints( int n)
{
N=n;
angleTheta = 360.0/n;
}
public double GetAngle() { return(angleTheta); }
public int GetN() { return(N); }
public static void main(String args[])
{
int N = Integer.parseInt(args[0]);
if (N>0)
{
CirclePoints myCircle = new CirclePoints(N);
double angleTheta = myCircle.GetAngle();
double angleX = angleTheta;
while (angleX <= 360)
{
double x = Math.cos(angleX*Math.PI/180);
double y = Math.sin(angleX*Math.PI/180);
System.out.println(" angle = " + angleX + " ordered pair: ("+x + "," + y+")");
angleX = angleX+angleTheta;
}
}
}
}
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
and YES, this ASSUMES the circle is centered at the origin with radius 1, that is the UNIT circle!!!12/14/19