Skip to content

Commit e214f4f

Browse files
committed
feat: Categorize website type based on domain extension using switch-case
🧠 Logic: - Accepts a website URL as user input and extracts the domain extension using `substring` after the last dot. - Uses a `switch-case` structure to identify and print the website type: - `.com` → Commercial Website - `.org` → Organization - `.gov` → Government - `.net` → Network - Converts extension to lowercase for case-insensitive matching. - Demonstrates practical string handling and conditional branching based on web domain classification. Signed-off-by: Somesh diwan <[email protected]>
1 parent 6c88336 commit e214f4f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Section7ConditionalStatements/src/SwitchCasesAB4.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22

33
import java.util.Scanner;
44

5-
public class SwitchCasesAB4
6-
{
7-
public static void main(String[] args)
8-
{
9-
5+
public class SwitchCasesAB4 {
6+
public static void main(String[] args) {
107
Scanner read = new Scanner (System.in);
118
System.out.print("Enter a Website URL To check In which category the website is belong: ");
129

1310
String Domain = read.nextLine();
14-
1511
String ext = Domain.substring(Domain.lastIndexOf(".")+1);
1612

17-
switch(ext.toLowerCase())
18-
{
13+
switch(ext.toLowerCase()) {
1914
case "com":
2015
System.out.println("commercial Website");
2116
break;
@@ -33,4 +28,4 @@ public static void main(String[] args)
3328
break;
3429
}
3530
}
36-
}
31+
}

0 commit comments

Comments
 (0)