Squares in a Circle.Difficulty: (2/5)
Let us define the Unit Grid as the set of 1x1 squares on the plane with corners that have integer coordinates. For example, the square with corners (1,1), (2,1), (1,2) and (2,2) is part of the unit grid.
Let C be a circle with center (x,y) and radius r.
Write a program that will take the center and radius of a circle (x, y and r) as as command line arguments and print out how many squares from the unit grid are completely covered by the circle. For example, given the input:
% java GridSquares 0.5 0.5 1.0the program should calculate the number of grid squares completely covered by the circle with center (0.5, 0.5) and radius 1.0, which happens to be 1.
To test your program, calculate the number of grid squares in a circle with center (0.25, 0.4) and radius 200.
CS1 Deadline: 11/15/2013
Use: handin cs1113 extra3 SquaresInCircle.java
Optional: Extend your program to deal with very large circles. Test your enhanced program on the circle with center (0.1, 0.1) and radius 200000. (Hint: You won't have time to count the squares one by one).