Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package math;
- import java.math.*;
- import java.util.Scanner;
- import java.lang.*;
- @SuppressWarnings("unused")
- public class Math extends Globals {
- public static void main(String[] args){
- Math math = new Math();
- Scanner userInput = new Scanner(System.in);
- System.out.println("Var vänlig skriv in x1 och x2, följt av y1 och y2");
- System.out.println("=================================================");
- System.out.print("X1:");
- int x1 = userInput.nextInt();
- System.out.print("X2:");
- int x2 = userInput.nextInt();
- System.out.print("Y1:");
- int y1 = userInput.nextInt();
- System.out.print("Y2:");
- int y2 = userInput.nextInt();
- if(x1 > x2 && y1 > y2)
- z = true;
- else
- z = false;
- double x3 = x1*x1;
- double x4 = x2*x2;
- double y3 = y1*y1;
- double y4 = y2*y2;
- if(z == true){
- double d2;
- d2 = (x3 - x4) + (y3 - y4);
- double d1;
- d1 = Math.sqrt(d2);
- System.out.println("The distance is: " + d1);
- }
- else{
- d2 = (x4 - x3) + (y4 - y3);
- d1 = Math.sqrt(d2);
- System.out.println("The distance is: " + d1);
- }
- }
- private static double sqrt(double d2) {
- // TODO Auto-generated method stub
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement