COS 126 General Computer Science S
Programming Exam 1
is test has 1 question. You have 50 minutes. The exam is open book, o u may use code from your
programming assignments or the Introduc va booksite. No communication with any non-staff members is
permitt Moodle. Write out and sign the Honor Code pledge before tu
pledge my honor that I have not violated the Honor Code during this e
The input consists of an integer N follo mbers (the x- and
y-coordinates of the center of the circle, followed b circles using standard drawing. Plot the
circle that intersects the mo re is a tie, plot the first circle in the input that has this
number of other circles it intersects.
% more intersects10.txt
.3 .4 .20
.1 .1 .02
.7 .5 .10
.3 .9 .08
.3 .8 .06
.4 .9 .06
.1 .6 .03
.5 .5 .12
.4 .4 .15
.9 .3 .02
% java Intersects < inte
(0.5, 0.5, 0.12)
bmission. Submit Intersects.java via Moodle.
oblem. Write a program Contains.java that reads in a sequence ut, plots them using standard
drawing, computes the circle that contai
d plots that circle in red, and prints to standard output the circle and tains.
ur program will be graded on correctness and clarity (including comme tial credit for a program
that solves part of the problem (e.g., reads i cles) than one that does not compile.
ometry. We specify a circle in the plane by its center (x, y) and its r cle j if the Euclidean
distance between their centers is less than or eq inus the radius of circle j.
(xi , y i , ri)