// Helene Martin, Garfield High School
// Demonstrates usage of Math methods and Scanner

import java.util.*;
import java.awt.*;

public class MathScannerExamples {
	public static void main(String[] args) {
		calculateDistance(10, 15, 30, 10);
		
		Scanner s = new Scanner(System.in);
		DrawingPanel p = new DrawingPanel(200, 200);
		Graphics g = p.getGraphics();
		
		for(int i = 0; i < 3; i++) {
			distanceCalculator(s, g);
		}
	}
	
	// Given x and y coordinates for two points, calculate length of line segment connecting them
	public static void calculateDistance(int x1, int y1, int x2, int y2) {
		double distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
		System.out.println("Distance between (" + x1 + ", " + y1 + ") and (" + x2 + ", " + y2 + "): " + distance);
	}
	
	// Prompts the user for two points, plots them and calculates the distance between them
	public static void distanceCalculator(Scanner s, Graphics g) {
		System.out.print("Your first point (enter x and y): ");
		int x1 = s.nextInt();
		int y1 = s.nextInt();
		System.out.print("Your second point (enter x and y): ");
		int x2 = s.nextInt();
		int y2 = s.nextInt();
		
		g.drawLine(x1, y1, x2, y2);
		calculateDistance(x1, y1, x2, y2);	
	}
}
