Skip to content

Instantly share code, notes, and snippets.

@bytecodeman
Created October 16, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytecodeman/86c8a5c2c211dbef19057893c0f931b6 to your computer and use it in GitHub Desktop.
Save bytecodeman/86c8a5c2c211dbef19057893c0f931b6 to your computer and use it in GitHub Desktop.
CSC-111 HW4 Point In Quarter Circle Solution
// A.C. Silvestri
// 10/11/17
// CSC-111-D01
// Homework 4 -- Point in Quarter Circle
// silvestri@.stcc.edu
import java.util.Scanner;
public class PointInQuarterCircle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please Radius of the Circle: ");
double radius = input.nextDouble();
if (radius <= 0)
System.out.println("Radius must be POSITIVE!");
else
{
System.out.print("Enter an x value: ");
double x = input.nextDouble();
System.out.print("Enter a y value: ");
double y = input.nextDouble();
boolean pointInCircle;
if (x < 0 || y < 0)
pointInCircle = false;
else
{
double dist = Math.sqrt(x * x + y * y);
pointInCircle = dist <= radius;
}
if (pointInCircle)
System.out.println("Point In Circle");
else
System.out.println("Point NOT In Circle");
}
input.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment