-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditional.java
More file actions
68 lines (58 loc) · 2.11 KB
/
Conditional.java
File metadata and controls
68 lines (58 loc) · 2.11 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
import java.util.Scanner;
import javax.swing.plaf.synth.SynthSpinnerUI;
public class Conditional {
public static void main(String[] args) {
// int a=5;
// if(a%2==0) System.out.println("EVEN");
// else System.out.println("ODD");
// String str;
// Scanner s = new Scanner(System.in);
// System.out.println("Enter a number");
// str = s.nextLine();
// if (str.matches("[01]+"))
// System.out.println("Binary");
// else if (str.matches("[0-7]+"))
// System.out.println("Octal");
// else if (str.matches("[0-9a-f]+"))
// System.out.println("Hexa");
// else
// System.out.println("Not a number");
// s.close();
// Leap Year
// int year;
// Scanner s = new Scanner(System.in);
// year = s.nextInt();
// if ((year % 4 == 0 && year % 100 == 0 && year % 400 == 0) || (year % 4 == 0
// && year % 100 != 0)) {
// System.out.println("Leap Year");
// } else {
// System.out.println("Not a leap year");
// }
// s.close();
// url parsing
String url;
Scanner s = new Scanner(System.in);
url = s.nextLine();
String protocol = url.substring(0, url.indexOf(":"));
// System.out.println(protocol);
String type = url.substring(url.indexOf(".") + 1);
// System.out.println(type);
if (protocol.equals("https"))
System.out.println("Hyper Text Transfer Protocol Secure");
else if (protocol.equals("ftp"))
System.out.println("File Transfer Protocol");
else if (protocol.equals("http"))
System.out.println("Hyper Text Transfer Protocol");
else
System.out.println("Not a Valid Protocol");
if (type.equals("com"))
System.out.println("Commercial");
else if (type.equals("gov"))
System.out.println("Government");
else if (type.equals("org"))
System.out.println("Organization");
else
System.out.println("Other");
s.close();
}
}