Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
92 lines (75 loc) · 2.74 KB
/
Copy pathMain.java
File metadata and controls
92 lines (75 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.awt.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Print the greeting below.
// System.out.println("Hello, Java!");
// Specifier Meaning
// %s string (any object — uses its toString)
// %d decimal integer
// %f floating point — defaults to 6 decimals
// %.2f floating point, exactly 2 decimals
// %5d integer right-aligned in 5 columns
// %-10s string left-aligned in 10 columns
// %n newline
// Scanner input = new Scanner(System.in);
// int firstNum = input.nextInt();
// int secondNum = input.nextInt();
// input.close();
// System.out.println(firstNum + secondNum);
// Scanner input = new Scanner(System.in);
// int width = input.nextInt();
// int height = input.nextInt();
// input.close();
// System.out.println(width * height);
// Scanner input = new Scanner(System.in);
// String sentence = input.nextLine();
// input.close();
// System.out.println(sentence.toUpperCase());
// Scanner input = new Scanner(System.in);
// String name = input.nextLine();
// int age = input.nextInt();
// input.close();
// System.out.println("Hi, " + name + "! You are " + age + " years old.");
// Scanner input = new Scanner(System.in);
// int number = input.nextInt();
// input.close();
// fizzbuzz(number);
// Scanner input = new Scanner(System.in);
// int number = input.nextInt();
// input.close();
// System.out.println(sumUpto(number));
// Scanner input = new Scanner(System.in);
// int number = input.nextInt();
// input.close();
// System.out.println(square(number));
Scanner input = new Scanner(System.in);
int x1 = input.nextInt();
int y1 = input.nextInt();
int x2 = input.nextInt();
int y2 = input.nextInt();
input.close();
System.out.println(pointDistanceSquared(x1, y1, x2, y2));
}
static void fizzbuzz(int number){
if (number % 15 == 0) {System.out.println("FizzBuzz");}
else if (number % 3 == 0) {System.out.println("Fizz");}
else if (number % 5 == 0) System.out.println("Buzz");
else System.out.println(number);
}
static int sumUpto(int number){
int sum = 0;
for (int i = 1; i <= number; i++){
sum += i;
}
return sum;
}
static int square(int n) {
return n * n;
}
static int pointDistanceSquared(int x1, int y1, int x2, int y2) {
int dx = x2 - x1;
int dy = y2 - y1;
return dx * dx + dy * dy;
}
}