CSC 190 Lecture 13: Code
Document Summary
//purpose: import java. util. scanner; public class p0211a { public static void main(string[] args) { //given a circle and a point, decide if the point lies inside, //outside or on the circle. double cx, cy, r, px, py; System. out. print("enter py: "); py = in. nextdouble(); double d = math. sqrt((px-cx)*(px-cx) + (py-cy)*(py-cy)); if (d < r) //purpose: import java. util. scanner; public class p0211b { public static void main(string[] args) { //two given circles c1 and c2, decide if they are disjoint, //overlapping double c1x, c1y, r1, c2x, c2y, r2; System. out. print("enter radius2: "); r2 = in. nextdouble(); d = math. sqrt((c2x-c1x)*(c2x-c1x) + (c2y-c1y)*(c2y-c1y)); if (d > r1+r2) System. out. println("c1 inside c2"); else if (d+r2 <= r1) //purpose: import java. util. scanner; public class p0211c { public static void main(string[] args) { //given two rectangles , decide if they are disjoint. //r1 inside r2, r2 inside r1, or they overlap double r1p1x, r1p1y, r1p2x, r1p2y; //top-left corner, bottom-right corner double r2p1x, r2p1y, r2p2x, r2p2y;