-
-
Save bytecodeman/86c8a5c2c211dbef19057893c0f931b6 to your computer and use it in GitHub Desktop.
CSC-111 HW4 Point In Quarter Circle Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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