Closed Thread
Results 1 to 5 of 5

Thread: need help with CS homework

  1. #1
    PinchTheBear is offline Newbie
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

    need help with CS homework

    Write a method, circlePlot, which takes as arguments an integer, n. The method should plot n points, evenly spaced around a circle.

    I'm using the StdDraw library and a single while loop.

    I don't even know where to begin.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: need help with CS homework

    One good thing would be to look up the StdDraw library and see what methods you have to use there.
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  4. #3
    PinchTheBear is offline Newbie
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

    Re: need help with CS homework

    The only method I need to use is StdDraw.point

    My issue is creating the loop:
    Code:
    public class circleFun {
      
       public static void circlePlot(int n) {
            StdDraw.clear();
            StdDraw.setPenColor(StdDraw.BLACK);
            StdDraw.setXscale(-1.1, 1.1);
            StdDraw.setYscale(-1.1,1.1);
    
        int ct = 0;
        StdDraw.setPenRadius(.01);
           
       while(n>=ct){
         StdDraw.point();
         
       
      
        //body of method
         
         ct=ct+1;
       }
       //end loop
    }}
    Last edited by Orjan; 02-26-2010 at 07:22 PM. Reason: Please use code tags when posting code

  5. #4
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: need help with CS homework

    Then I assume you need to calculate which points to draw. Think sinus and cosinus for the angle to calculate the coordinates. the angle should rely on number of points to have them evenly distributed (if more than n=1)

    the unit circle would help you a lot with solving this I assume.
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  6. #5
    PinchTheBear is offline Newbie
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

    Re: need help with CS homework

    Right, okay. So then the only values of n that will work will need to be multiples of 4.. that narrows it down a bit.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I can do your homework!
    By FrozenSnake in forum C and C++
    Replies: 6
    Last Post: 03-26-2010, 04:40 PM
  2. help with homework
    By rajan in forum C and C++
    Replies: 7
    Last Post: 03-26-2010, 05:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

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