Skip to content

Commit 9ea8f4a

Browse files
authored
Add files via upload
1 parent d615627 commit 9ea8f4a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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)