Skip to content

Commit 6e82118

Browse files
Merge pull request #290 from SOMAN-SABEEL/main
Minor changes
2 parents 66e5554 + 9ea8f4a commit 6e82118

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

Host-checker.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import java.io.IOException;
2+
import java.net.HttpURLConnection;
3+
import java.net.URL;
4+
import java.util.Scanner;
5+
6+
public class WebsiteStatusChecker {
7+
public static void main(String[] args) {
8+
Scanner scanner = new Scanner(System.in);
9+
System.out.print("Enter the website URL to check: ");
10+
String urlToCheck = scanner.nextLine();
11+
12+
try {
13+
int statusCode = checkWebsiteStatus(urlToCheck);
14+
15+
if (statusCode >= 200 && statusCode < 400) {
16+
System.out.println("Website is alive (HTTP Status Code: " + statusCode + ")");
17+
} else {
18+
System.out.println("Website is down (HTTP Status Code: " + statusCode + ")");
19+
}
20+
} catch (IOException e) {
21+
System.err.println("Error checking website status: " + e.getMessage());
22+
}
23+
}
24+
25+
public static int checkWebsiteStatus(String url) throws IOException {
26+
URL websiteURL = new URL(url);
27+
HttpURLConnection connection = (HttpURLConnection) websiteURL.openConnection();
28+
connection.setRequestMethod("GET");
29+
connection.connect();
30+
int statusCode = connection.getResponseCode();
31+
connection.disconnect();
32+
33+
return statusCode;
34+
}
35+
}

loading-annimation.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.Scanner;
2+
3+
public class LoadingAnimation {
4+
public static void main(String[] args) {
5+
Scanner scanner = new Scanner(System.in);
6+
7+
System.out.print("Enter the loading percentage (0-100): ");
8+
int percentage = scanner.nextInt();
9+
scanner.close();
10+
11+
if (percentage < 0 || percentage > 100) {
12+
System.out.println("Invalid input. Percentage must be between 0 and 100.");
13+
return;
14+
}
15+
16+
int width = 50; // Width of the loading bar
17+
int progress = (int) (width * (percentage / 100.0)); // Calculate the progress
18+
19+
System.out.print("Loading: [");
20+
for (int i = 0; i < width; i++) {
21+
if (i < progress) {
22+
System.out.print("=");
23+
} else {
24+
System.out.print(" ");
25+
}
26+
}
27+
System.out.println("] " + percentage + "% Complete");
28+
}
29+
}
30+

0 commit comments

Comments
 (0)